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

Prelin Grass 3

CLICK  =>  RESTART
*
*    DOUBLE CLICK  =>  TOGGLE FULL SCREEN
*
Get Adobe Flash player
by Yukulele 24 Sep 2009
/**
*
*           CLICK  =>  RESTART
*
*    DOUBLE CLICK  =>  TOGGLE FULL SCREEN
*
*/


package 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
        import flash.display.StageDisplayState;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
	import flash.events.Event;
        import flash.events.FullScreenEvent;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
        import flash.geom.Rectangle;
	import flash.utils.Timer;
	[SWF(backgroundColor="0x000000")]
	/**
	 * ...
	 * @author Yukulélé
	 */
	public class Main extends Sprite 
	{
		
		private var bd:BitmapData = new BitmapData(50, 50);
		private var tableau:Array;
		private var rx:Number;
		private var ry:Number;
		private var tx:Number;
		private var ty:Number;
		private var nbr:int;
		public function Main():void 
		{
			Wonderfl.disable_capture();
			Wonderfl.capture_delay( 10 );
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
                        stage.fullScreenSourceRect = new flash.geom.Rectangle(0, 0, stage.fullScreenWidth*.75, stage.fullScreenHeight*.75);
			stage.frameRate = 60;
                        stage.scaleMode = StageScaleMode.NO_SCALE;
                        stage.align = StageAlign.TOP_LEFT;
                        stage.doubleClickEnabled=true;
                        stage.addEventListener(MouseEvent.DOUBLE_CLICK,function():void{
                            stage.displayState = stage.displayState==StageDisplayState.NORMAL
                                ?StageDisplayState.FULL_SCREEN
                                :StageDisplayState.NORMAL;
                        });
                        stage.addEventListener(MouseEvent.CLICK,function():void{
                            debut();
                        })
                        stage.addEventListener(FullScreenEvent.FULL_SCREEN, function(e:FullScreenEvent):void 
                        {
                            debut(); 
                        });
                        debut();
                        
                }
                private function debut():void
                {
                        nbr=Math.sqrt(stage.stageWidth*stage.stageHeight)*4;
                        //nbr=(stage.stageWidth*stage.stageHeight)/200;
                        while(numChildren>0)
                            removeChildAt(0);
                        tableau=new Array();
                        tx = stage.stageWidth;
			ty = stage.stageHeight;
			rx = bd.width / tx;
			ry = bd.height / ty;
			maj2();
			//addChild(new Bitmap(bd));
			for (var i:int = 0; i < nbr; i++)
			{
				var s:Particule = new Particule();
				s.x = Math.random() * tx;
				s.y = Math.random() * ty;
				s.rotation = Math.random() * 180;
				s.graphics.beginFill((recupPixel(s.x, s.y)&0x3ff7f7),.75);
                                //s.graphics.drawEllipse(-15, -.35, 30, .7);
				
                                s.graphics.moveTo(-15,15);
                                s.graphics.lineTo(0,16.35);
                                s.graphics.lineTo(15,15);
                                s.graphics.lineTo(0,16);
                                s.graphics.endFill();
                                tableau.push(s);
				addChild(s);
			}
			var t2:Timer = new Timer(100);
			addEventListener(Event.ENTER_FRAME, maj);
			t2.addEventListener(TimerEvent.TIMER, maj2);
			t2.start();
		}
		private function maj(e:Event):void
		{
			for (var i:int = 0; i < nbr; i++)
			{
				var s:Shape = tableau[i];
				var b:int = recupPixel(s.x, s.y)&0xff;
				s.rotation = (((b / 0xff - .5) * 360) * .4 + s.rotation * .95);
				s.scaleY = (Math.cos((s.rotation)/60))+1.2;
			}
		}
		private function maj2(e:TimerEvent=null):void
		{
			bd.perlinNoise(20+Math.random()*10, 20+Math.random()*10, 3, Math.random() * int.MAX_VALUE,false, true, 7, false);
		}
		private function recupPixel(x:Number, y:Number):uint
		{
			return bd.getPixel(x * rx, y * ry);
		}
	}
}
class Particule extends flash.display.Shape
{
	private var _rot:Number;
	public function Particule()
	{
		_rot = 0;
	}
	public override function get rotation():Number
	{
		return _rot;
	}
	public override function set rotation(r:Number):void
	{
		_rot = r;
		super.rotation = r;
	}
}