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: Baby

Get Adobe Flash player
by kazu_E09 11 Jan 2010
// forked from hiro_rec's Baby
package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BitmapDataChannel;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.BlurFilter;
	import flash.filters.DisplacementMapFilter;
	import flash.geom.Point;
	import flash.net.URLRequest;
	import flash.system.Security;

	public class Main extends Sprite
	{
		private static const LEVEL:uint = 1;
		private static const BLUR:BlurFilter = new BlurFilter(10, 10, BitmapFilterQuality.LOW);
		
		private var container:Sprite;
		private var originalBmd:BitmapData;
		private var bmd:BitmapData;
		private var bmp:Bitmap;

		private var sx:Number = .0;
		private var sy:Number = .0;
		
		
		[SWF(backgroundColor="0x000000", frameRate="30")]
		
		public function Main()
		{
			Security.loadPolicyFile("http://start-rec.net/crossdomain.xml"); 
			
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadCompleteHandler);
			loader.load(new URLRequest("http://start-rec.net/data/wonderfl/images/baby.jpg"));
		}
		
		private function imageLoadCompleteHandler(event:Event):void
		{
			container = new Sprite();
			addChild(container);
			
			bmp = Bitmap(event.target.content);
			originalBmd = bmp.bitmapData;
			
			bmd = originalBmd.clone();
			bmp = new Bitmap(bmd);
			
			container.addChild(bmp);
			
			addEventListener(Event.ENTER_FRAME, enterFrameHandler);
		}
		
		private function enterFrameHandler(event:Event):void
		{	
			sx += ((stage.stageWidth / 2 - stage.mouseX) * 0.1 - sx) * 0.1;
			sy += ((stage.stageHeight / 2 - stage.mouseY) * 0.1 - sy) * 0.1;
			
			bmd.draw(originalBmd);
			
			var mapFilter:DisplacementMapFilter = new DisplacementMapFilter(bmd, new Point(), BitmapDataChannel.RED, BitmapDataChannel.RED, sx, sy, "wrap", 0, 0);
			bmp.filters = [mapFilter];
			
			bmd.draw(container);
			bmd.applyFilter(bmd, bmd.rect, new Point(), BLUR);
			
			bmd.draw(container);
		}
	}
}