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

Flower

Get Adobe Flash player
by 12px 25 Dec 2008
package
{
    import flash.utils.Timer;
    import flash.events.TimerEvent;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.geom.ColorTransform;
	import flash.filters.BlurFilter;
	import flash.display.MovieClip;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	
	[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="30")]	
	
	public class Flower extends MovieClip
	{
		//----------------------------------------------------------------------------------------------------
		
		// properties
		private var _base:Object;
		private var _prop:Object;
		
		//----------------------------------------------------------------------------------------------------
		
		// constructor
		public function Flower()
		{
			startDrawing();
		}
		
		//----------------------------------------------------------------------------------------------------
		
		// code
		private function startDrawing():void
		{
			_base = this;
			_prop = {};
			_prop.bgColor = 0x000000;
			_prop.pixelColor = 0xffffff;
			_prop.defaultWidth = 465;
			_prop.defaultHeight = 465;
			_prop.ang = 12;
			_prop.pAry = addParticle(3600);
			//
			_prop.bmd = new BitmapData( _prop.defaultWidth , _prop.defaultHeight , false , _prop.bgColor);
			_prop.bm = new Bitmap( _prop.bmd );
			_base.addChild(_prop.bm);
			_base.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
			//
			_base.stage.addEventListener(MouseEvent.MOUSE_UP, _onStageMouseUp);
			//
			_prop.timer = new Timer(3000);
			_prop.timer.addEventListener(TimerEvent.TIMER, timerhandler);
			_prop.timer.start();
		}
		private function _onStageMouseUp(e:MouseEvent):void
		{
			_prop.timer.reset();
			_prop.timer.start();
			update();
		}
		private function timerhandler(event:TimerEvent):void
		{
			update();
		}
		private function _onEnterFrame(event:Event):void
		{
			for(var i:int=10; i<_prop.pAry.length; i++){
				if(i%2 == 1){
					_prop.pAry[i].x = Math.cos(_prop.ang*i)*i*.1 + _prop.defaultWidth/2;
					_prop.pAry[i].y = Math.sin(_prop.ang*i)*i*.1 + _prop.defaultHeight/2;
				} else{
					_prop.pAry[i].x = Math.sin(_prop.ang*i)*i*.1 + _prop.defaultWidth/2;
					_prop.pAry[i].y = Math.cos(_prop.ang*i)*i*.1 + _prop.defaultHeight/2;
				}
			}
			_prop.ang += .000001;
			//
			for(var ii:int=10; ii<_prop.pAry.length-1; ii++){
				_prop.bmd.setPixel(_prop.pAry[ii].x, _prop.pAry[ii].y, _prop.pixelColor);
			}
			_prop.bmd.colorTransform( _prop.bmd.rect, new ColorTransform( 1, 1, 1, 1, (Math.random()*-2)-1, (Math.random()*-2)-1, (Math.random()*-2)-1, 1 ) );
			_prop.bmd.applyFilter(_prop.bmd, _prop.bmd.rect, new Point(0, 0), new BlurFilter(2, 2, 4));
		}
		private function update():void
		{
			_prop.ang += randomNumberRange(1, 10);
		};
		
		// particle
		private function addParticle(num:Number):Array
		{
			_prop.container = new MovieClip();
			var ar:Array = [];
			for(var i:int=0; i<num; i++){
				var s:Object = {};
				s.id = i;
				ar.push(s);
			}
			return ar;
		}
		
		//----------------------------------------------------------------------------------------------------
		
		//util
        	public static function randomNumberRange(min:Number, max:Number):Number { return min + Math.random()*(max+1 - min) };
		
		//----------------------------------------------------------------------------------------------------
		
	}
	
}