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

キモtrail

Get Adobe Flash player
by dfrm 06 Aug 2009
    Embed
/**
 * Copyright dfrm ( http://wonderfl.net/user/dfrm )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/q59e
 */

package {
	import flash.display.BitmapData;
	import flash.display.Bitmap;
	import flash.display.BlendMode;
	import flash.display.PixelSnapping;
        import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.filters.DisplacementMapFilter;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.geom.Rectangle;
    
    [SWF(width="465", height="465", backgroundColor="0xffffff", frameRate="30")]
    
    public class Tracking extends Sprite {
		
		public const WIDTH:Number = 465;
		
		public var dc:Number = 3;
		public var m:Number = 30;
		
		private var r:Rectangle;
		private var ctrs:ColorTransform;
		private var b:Array = [];
		private var pp:Point = new Point();
		
		private var temp:Sprite;
		private var pn:BitmapData;
		private var c:BitmapData;
		private var g:BitmapData;
		
        public function Tracking() {
            // write as3 code here..
			Init();
        }
		
		private function Init():void {
			r = new Rectangle(0, 0, WIDTH, WIDTH);
			
			c = new BitmapData(WIDTH, WIDTH, false, 0x0);
			addChild(new Bitmap(c)) as Bitmap;
			
			g = new BitmapData(WIDTH / 4, WIDTH / 4, false, 0x0);
			var bm:Bitmap = addChild(new Bitmap(g, PixelSnapping.NEVER, true))as Bitmap;
			bm.scaleX = bm.scaleY = 4;
			bm.blendMode = BlendMode.ADD;
			
			pn = new BitmapData(WIDTH, WIDTH, false, 0x0);
			pn.perlinNoise(100, 100, 2, 1, false, true, 5);
			
			ctrs = new ColorTransform(0.97, 0.92, 0.95, 1);
			
			temp = new Sprite();
			addChild(temp);
			
			for (var i:int = 0; i < m; i++) {
				b.push(new Sprite());
				b[i].graphics.beginFill(0xffffff,1/i);
				b[i].graphics.drawCircle(0,0,2+i);
				b[i].graphics.endFill();
				temp.addChild(b[i]);
			}
			addEventListener(Event.ENTER_FRAME, _loop);
		}
		
		private function _loop(e:Event):void {
			for (var i:int = 0; i < b.length; i++) {
				if(i==0){
					pp.x = mouseX;
					pp.y = mouseY;
				}else {
					pp.x = b[i - 1].x + Math.random()*10-5;
					pp.y = b[i - 1].y + Math.random()*10-5;
				}
				
				b[i].x += (pp.x - b[i].x) / (dc);
				b[i].y += (pp.y - b[i].y) / (dc);
			}
			
			c.lock();
			c.colorTransform(r, ctrs);
			c.applyFilter(c, r, new Point(), new BlurFilter(3, 3));
			c.draw(temp);
			c.unlock();
			
			g.draw(c, new Matrix(0.25, 0, 0, 0.25));
			g.applyFilter(g, r, new Point(), new BlurFilter(5, 5));
		}
	}
}