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 2009-6-18

Get Adobe Flash player
by sw_lucchini 18 Jun 2009
    Embed
/**
 * Copyright sw_lucchini ( http://wonderfl.net/user/sw_lucchini )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7z0Z
 */

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	[SWF(width="465",height="465",frameRate="60",backgroundColor="0x000000")]
	public class Main extends Sprite
	{
		private var pt1:Point;
		private var pt2:Point;
		private var stageRect:Rectangle;
		
		public function Main()
		{
			init();
		}
		
		private function init():void
		{
			stageRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
			pt1 = pt2 = new Point(stage.stageWidth / 2, stage.stageHeight / 2);
			addEventListener(Event.ENTER_FRAME, updatePoints);
			stage.addEventListener(MouseEvent.MOUSE_DOWN, clearStage);
		}
		
		private function updatePoints(e:Event):void
		{
			pt1 = pt2;
			var len:uint = Math.round(Math.random() * 30);
			var angle:uint = Math.round(Math.random() * 4 * Math.PI);
			pt2 = Point.polar(len, angle);
			pt2.offset(pt1.x, pt1.y);
			if (stageRect.containsPoint(pt2)) {
				drawLine(pt1, pt2);
			}else {
				pt2 = pt1;
			}
		}
		
		private function drawLine(ptA:Point, ptB:Point):void
		{
			var color:uint = Math.random() * 0x666666;
			var alpha:Number = Math.random() * 1;
			graphics.lineStyle(2, color, alpha);
			graphics.moveTo(ptA.x, ptA.y);
			graphics.lineTo(ptB.x, ptB.y);
		}
		
		private function clearStage(e:MouseEvent):void
		{
			graphics.clear();
		}
	}
}