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

Draw1

Get Adobe Flash player
by deadelvis 26 Feb 2009
package {
	
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.ui.*;
	import caurina.transitions.Tweener;
	
	[SWF(backgroundColor="#000000", frameRate="30")]

	public class Draw1 extends Sprite {
		
		private var _canvas:Sprite;
		private var _obj:Object;
		
		public function Draw1() {
			_obj = {};
			_obj.x = stage.stageWidth * .5;
			_obj.y = stage.stageHeight * .5;
			createCanvas();
		}
		
		private function createCanvas(width:int = 460, height:int = 460):void {
			_canvas = new Sprite();
			cacheAsBitmap = true;
			_canvas.cacheAsBitmap = true;
			_canvas.graphics.lineStyle(5, 0xffffff, 1, false, LineScaleMode.NONE, CapsStyle.ROUND);
			_canvas.graphics.moveTo(_obj.x, _obj.y);
			addChild(_canvas);
			_canvas.addEventListener(Event.ENTER_FRAME, loop);
			randomTween(getRandomData());
		}
		
		private function loop(e:Event):void {
			_canvas.x -= 4;
			var p:Point = _canvas.globalToLocal(new Point(_obj.x, _obj.y));
			_canvas.graphics.lineTo(p.x, p.y);
		}
		
		private function randomTween(o:Object):void {
			Tweener.addTween(_obj, {y:o.y, time:o.time, transition:"easeInOutElastic", onComplete:
				function():void {
					randomTween(getRandomData());
				}
			});
		}
		
		private function getRandomData():Object {
			var o:Object = {};
			o.y = Math.round(Math.random() * stage.stageHeight);
			o.time = Math.random() * 3 + 1;
			return o;
		}
			
	}

}