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

forked from: Colorful Rings

basic logic from yossy a.k.a. BeInteractive
http://www.be-interactive.org/?itemid=278
Get Adobe Flash player
by jam 04 Feb 2009
// forked from ton's Colorful Rings
// basic logic from yossy a.k.a. BeInteractive
// http://www.be-interactive.org/?itemid=278

package {
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Matrix;
	
	[SWF(width="465", height="465", backgroundColor="0xffffff", frameRate="40")]
	
	public class KaleidoscopeLogic extends Sprite {
		
		private var container:Sprite;
		private var bmd:BitmapData;
		private var base:BitmapData;
		
		private var mtx_ul:Matrix;		// Matrix positions at upper left
		private var mtx_ur:Matrix;		// Matrix positions at upper right
		private var mtx_ll:Matrix;		// Matrix positions at lower left
		private var mtx_lr:Matrix;		// Matrix positions at lower right
		
		
		public function KaleidoscopeLogic() {
			container = new Sprite();
			base = new BitmapData( 465, 465, false );
			
			mtx_ul = new Matrix();
			mtx_ur = new Matrix();
			mtx_ur.scale( -1, 1 );
			mtx_ur.translate( 465, 0 );
			mtx_ll = new Matrix();
			mtx_ll.scale( 1, -1 );
			mtx_ll.translate( 0, 465 );
			mtx_lr = new Matrix();
			mtx_lr.scale( -1, -1 );
			mtx_lr.translate( 465, 465 );
			
			addChild( new Bitmap( base ) );
			addEventListener( Event.ENTER_FRAME, onEnterFrameHandler );
		};
		
		private function onEnterFrameHandler( e:Event ):void {
			base.lock();
			
			bmd = new BitmapData( 233, 233, true );
			
			createRings( bmd );
			drawBaseBitmapData( base, bmd );
			
			bmd.dispose();
			
			base.unlock();
		};
		
		private function createRings( src:BitmapData ):void {
			var ring:Ring = new Ring( Math.random() * 90 + 10, Math.random() * 0xFFFFFF );
			ring.x = Math.random() * 320;
			ring.y = Math.random() * 240;
			
			container.addChild( ring );
			src.draw( container );
		};
		
		private function drawBaseBitmapData( dest:BitmapData, source:BitmapData ):void {
			dest.fillRect( dest.rect, 0xFFFFFFFF );
			dest.draw( source, mtx_ul );
			dest.draw( source, mtx_ur );
			dest.draw( source, mtx_ll );
			dest.draw( source, mtx_lr );
		};
		
		
	};
	
};




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

class Ring extends Sprite {
	
	private const DECAY:Number = 0.95;
	
	public function Ring( size:int = 30, color:uint = 0x000000 ) {
		this.graphics.clear();
		this.graphics.lineStyle( Math.random() * 10, color );
		this.graphics.drawCircle( 200, 200, size );
		addEventListener( Event.ENTER_FRAME, onEnterFrameHandler );
	};
	
	private function onEnterFrameHandler( e:Event ):void {
		this.scaleX *= DECAY;
		this.scaleY *= DECAY;
		
		if( this.scaleX <= 0.01 ) {
			this.parent.removeChild( this );
			removeEventListener( Event.ENTER_FRAME, onEnterFrameHandler );
		}
	};
	
};