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

lines2

Get Adobe Flash player
by deadelvis 26 Feb 2009
package {
	import flash.display.Sprite;
	import flash.utils.Timer;  
	import flash.events.TimerEvent;
	import flash.display.StageScaleMode;
	
	public class Lines2 extends Sprite {

		var midP = new Object();	
		var P0 = new Object();
		var P1 = new Object();
		var P2 = new Object();
		var P3 = new Object();
	
		var thickness:Number = 0;
		var thickness_inc:Number = 1;
		var thickness_max:Number = 2;
		var line_alpha:Number = 0.3;

		public function Lines2() {
			stage.scaleMode = StageScaleMode.NO_SCALE;
			cacheAsBitmap = true;
			var myTimer:Timer = new Timer(150);  
			myTimer.addEventListener("timer", calc);  
			myTimer.start();  
      	
		}

		// This function draws a approximation of a cubic bezier curve
		// It is very fast but does not look quite the real one
		function drawCubicBezier_spline(P0, P1, P2, P3){
			// calculates middle point of the two control points segment
			midP.xx = (P1.xx + P2.xx) / 2;
			midP.yy = (P1.yy + P2.yy) / 2;
			// draw fake cubic bezier curve lines (in two parts)
			graphics.curveTo(P1.xx, P1.yy, midP.xx, midP.yy);
			graphics.curveTo(P2.xx, P2.yy, P3.xx, P3.yy);
		}
	
		function calc(e:TimerEvent=null){
			thickness = thickness+thickness_inc;
			if(thickness >= thickness_max){
				thickness_inc = -1;
			}else
			if(thickness<=0){
				thickness_inc = 1;
			}
			
			graphics.lineStyle(thickness, 0x000000, line_alpha);
			
			P0.xx = P3.xx;
			P0.yy = P3.yy;
			P1.xx = P0.xx + P0.xx - P2.xx;
			P1.yy = P0.yy + P0.yy - P2.yy;

			P2.xx = Math.random()*stage.stageWidth;
			P2.yy = Math.random()*stage.stageHeight;
			P3.xx = Math.random()*stage.stageWidth;
			P3.yy = Math.random()*stage.stageHeight;

			drawCubicBezier_spline(P0,P1,P2,P3);
			
		}
	}
}