In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

RandomCircle

RandomCircle.as
Get Adobe Flash player
by kadal 03 Apr 2009
    Embed
/* RandomCircle.as */
package {
	import flash.display.Sprite;
	import flash.display.Graphics;
	import flash.display.DisplayObject;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import flash.events.Event;
	import flash.filters.BlurFilter;

        [SWF(backgroundColor="#FFFFFF", frameRate=30)]

	public class RandomCircle extends Sprite {
		public function RandomCircle() {
			var timer:Timer = new Timer(20, 0);
			timer.addEventListener(TimerEvent.TIMER, myCircle);
			timer.start();
		}
        
		private function myCircle(evt:TimerEvent):void {
			var p:Sprite = new Sprite();
			p.graphics.beginFill(Math.random() * 0xFFFFFF);
			p.graphics.drawCircle(0, 0, Math.random() * 500);
			p.x = Math.random() * stage.stageWidth;
			p.y = Math.random() * stage.stageHeight;
			p.graphics.endFill();
			p.alpha = 0;
			addChild(p);
			p.addEventListener(Event.ENTER_FRAME, smaller);
		}

		private function smaller(evt:Event):void{
			var p:Object = evt.target;
			p.alpha += 0.01;
			p.scaleX *= 0.96;
			p.scaleY *= 0.96;
			p.x -= ((stage.stageWidth/2)-p.x)/1000;
			p.y -= ((stage.stageHeight/2)-p.y)/1000;
			if(p.width < 1){
				p.visible = false;
				p.removeEventListener(Event.ENTER_FRAME, smaller);
				removeChild(DisplayObject(p));
			}
		}
	}
}