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

flash on 2010-4-13

Get Adobe Flash player
by kihon 13 Apr 2010
/**
 * Copyright kihon ( http://wonderfl.net/user/kihon )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ijV8
 */

package
{
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.display.BitmapData;
	import flash.events.Event;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.net.URLRequest;
	import flash.system.LoaderContext;
 
	public class Main extends Sprite
	{
		private var bd:BitmapData;
		private var maskbd:BitmapData;
		private var temp:BitmapData;
		private var image:BitmapData;
		private var count:int = 0;
 
		public function Main()
		{
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
			loader.load(new URLRequest("http://assets.wonderfl.net/images/related_images/2/28/28ab/28ab32110250938b9e1f0d3a0c0854fc5abaab1d"), new LoaderContext(true));
		}
 
		private function initHandler(event:Event):void
		{
			var loader:Loader = event.currentTarget.loader;
			var scale:Number = (loader.width > loader.height) ? stage.stageWidth / loader.width : stage.stageHeight / loader.height;
			var matrix:Matrix = new Matrix();
			matrix.scale(scale, scale);
			image = new BitmapData(loader.width, loader.height, true, 0x0);
			image.draw(loader, matrix);
 
			maskbd = new BitmapData(loader.width, loader.height, true, 0x0);
 
			temp = new BitmapData(loader.width, loader.height, true, 0x0);
 
			bd = new BitmapData(loader.width, loader.height, true, 0x0);
			var bitmap:Bitmap = new Bitmap(bd);
			addChild(bitmap);
 
			maskbd.copyPixels(image, image.rect, new Point());
 
			init();
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
 
		private function init():void
		{
			count = 0;
			bd.fillRect(bd.rect, 0xFFFFFF);
		}
 
		private function onEnterFrame(event:Event):void
		{
			temp.fillRect(temp.rect, 0x0); 
			temp.threshold(maskbd, maskbd.rect, new Point(), "<=", count, 0xFF000000, 0xFF);
			bd.copyPixels(image, image.rect, new Point(), temp, new Point());
 
			if (count++ == 0xFF) init();
		}
	}
}