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: perlinNoise()の練習

Get Adobe Flash player
by azAZ09 03 Aug 2009
// forked from rsakane's perlinNoise()の練習
package
{
	import flash.display.Sprite;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BlendMode;
	import flash.events.Event;
	import flash.geom.Point;
	
	[SWF(width="465", height="465", frameRate="10", backgroundColor="0xFFFFFF")]
	public class Main extends Sprite
	{
		private var bitmap:Bitmap;
		private var blend:Bitmap;
		private var frameCount:int;
		private var color:int = 0x9BC6CC;
		private var s:int = 5;
		
		public function Main()
		{
			//Wonderfl.capture_delay(10); 
			bitmap = new Bitmap(new BitmapData(stage.stageWidth / 4, stage.stageHeight / 4, false));
			bitmap.alpha = 0.6;
			addChild(bitmap);
			
			blend = new Bitmap(new BitmapData(bitmap.width, bitmap.height, false, color));
			blend.blendMode = BlendMode.OVERLAY;
			addChild(blend);
			
			bitmap.scaleX = bitmap.scaleY = blend.scaleX = blend.scaleY = 4;
			
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		
		private function onEnterFrame(event:Event):void
		{
			frameCount += 4;
			var offsets:Array = new Array();
			for (var i:int = 1; i <= 10; i++) offsets.push(new Point(frameCount / i, frameCount / i));
			bitmap.bitmapData.perlinNoise(150, 161, 5, 3, false, false, 0, true, offsets);
			
			if (frameCount % 20 == 0)
			{
				removeChild(blend);
				blend = null;
				blend = new Bitmap(new BitmapData(bitmap.width, bitmap.height, false, color));
				addChild(blend);
				blend.blendMode = BlendMode.OVERLAY;
				blend.scaleX = 4;
				blend.scaleY = 4;
				
				if (s > 0 && color + s > 0x9BC6FF) s *= -1;
				else if(s < 0 && color + s < 0x9BC6CC) s *= -1;
				else color += s;
			}
		}
	}
}