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 2

...
@author Yukulélé
Get Adobe Flash player
by Yukulele 26 Apr 2009
package 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	[SWF(backgroundColor=0x000000)]
	/**
	 * ...
	 * @author Yukulélé
	 */
	public class Main extends Sprite 
	{
		
		private var bd:BitmapData = new BitmapData(100, 100);
		private var tableau:Array=new Array;
		private var rx:Number;
		private var ry:Number;
		private var tx:Number;
		private var ty:Number;
		private var nbr:int = 3000;
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			tx = stage.stageWidth;
			ty = stage.stageHeight;
			rx = bd.width / tx;
			ry = bd.height / ty;
			//addChild(new Bitmap(bm));
			maj2();
			for (var i:int = 0; i < nbr; i++)
			{
				var s:Shape = new Shape();
				s.x = Math.random() * tx;
				s.y = Math.random() * ty;
				s.rotation = Math.random() * 180;
				s.graphics.beginFill((recupPixel(s.x, s.y)&0x3ff7f7),.5);
				s.graphics.drawEllipse(-10, -1, 20, 2);
				//s.graphics.drawRect( -8, -1, 16, 2);
				tableau.push(s);
				addChild(s);
			}
			var t:Timer = new Timer(15);
			var t2:Timer = new Timer(100);
			t.addEventListener(TimerEvent.TIMER, maj);
			t.start();
			t2.addEventListener(TimerEvent.TIMER, maj2);
			t2.start();
		}
		private function maj(e:TimerEvent):void
		{
			for (var i:int = 0; i < nbr; i++)
			{
				var s:Shape = tableau[i];
				var col:uint = recupPixel(s.x, s.y);
				var b:int = (col)&0xff;
				//s.x += (r - 0xff / 2) / 100;
				//s.y += (v - 0xff / 2) / 100;
				s.rotation = (((b / 0xff - .5) * 360) * .25 + s.rotation * .9);
				s.alpha = Math.abs(Math.cos((s.rotation+10) * Math.PI / 60))+.7;
			}
		}
		private function maj2(e:TimerEvent=null):void
		{
			bd.perlinNoise(100, 100, 5, Math.random()*int.MAX_VALUE,true,true,7,false);
		}
		private function recupPixel(x:Number, y:Number):uint
		{
			return bd.getPixel(x * rx, y * ry);
		}
		
	}
	
}