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

Colorful Rings

Get Adobe Flash player
by ton 13 Jan 2009
package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
   
    [SWF(width=465, height=465, frameRate=30, backgroundColor=0xffffff)]
    public class ColorfulRings extends Sprite {
		public function ColorfulRings():void {
			addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
		}
		
		private function onEnterFrameHandler(e:Event):void {
			var ring:Ring = new Ring(Math.random() * 90 + 10, Math.random() * 0xffffff);
			addChild(ring);
			ring.x = Math.random() * stage.stageWidth;
			ring.y = Math.random() * stage.stageHeight;
		}	
    }
}

import flash.display.Sprite;
import flash.events.Event;

class Ring extends Sprite {
	private const SCALE:Number = 0.05;

	public function Ring(size:int = 30, color:uint = 0x000000) {
		this.graphics.lineStyle(Math.random() * 10, color);
		this.graphics.drawCircle(0, 0, size);
		addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
	}
		
	private function onEnterFrameHandler(e:Event):void {
		this.scaleX -= SCALE;
		this.scaleY -= SCALE;
		
		if (this.scaleX <= 0) {
			this.parent.removeChild(this);
			removeEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
		}		
	}	
}