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

LineThing

package  {	
	
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.DropShadowFilter;
	import flash.filters.GlowFilter;
	import flash.utils.getTimer;
	[SWF(width = "950", height = "500", frameRate = "41", backgroundColor = "#000000", pageTitle = "milkmidi.com")]	
	public class LineThing extends Sprite{
		private var points:Array = new Array();
		private var prevmouseX:Number = 0;
		private var prevmouseY:Number = 0;
		private var draw_mc:Sprite = new Sprite();
		//_________________________Constructor
		public function LineThing() {
			var glow0:GlowFilter = new GlowFilter(0xffffff, 1, 16, 8, 1, 3, true, false);
			var glow1:GlowFilter = new GlowFilter(0xffff00, 1, 8, 8, 1, 3, false, false);
			var dropShadow0:DropShadowFilter = new DropShadowFilter(0, 90, 0xcc3300, 1, 64, 64, 5, 3, false, false, false);
			draw_mc.filters = [glow0, glow1, dropShadow0];			
			this.addChild(draw_mc);
			this.addEventListener(Event.ENTER_FRAME,onEventEnterFrame);
		}


		private function onEventEnterFrame(e:Event):void  {
			var _g:Graphics = draw_mc.graphics;
			_g.clear();
			_g.lineStyle(2, 0x99CC00);
			var dx:Number = this.mouseX - prevmouseX;
			var vx:Number = dx ? dx : Math.random() * randSet(-1, 1);
			var dy:Number = this.mouseY - prevmouseY;
			var vy:Number = dy ? dy : Math.random() * randSet(-1, 1);	
			var pLen:Number = points.push({x:this.mouseX, y:this.mouseY, vx:vx / 10, vy:vy / 10, life:getTimer()});
			for (var i:Number = 0; i < pLen; i++) {
				if (!points[i]) {
					continue
				}
				if (getTimer() - points[i].life > 1000) {					
					points.splice(i--, 1)					
				} else {
					if (i!=0 && points[i]) {				
						points[i].x += points[i].vx;
						points[i].y += points[i].vy;
						var cx:Number = points[i - 1].x;
						var cy:Number = points[i - 1].y;
						_g.curveTo(cx, cy, (points[i].x + cx) / 2, (points[i].y + cy) / 2);
					} else {
						_g.moveTo(points[i].x, points[i].y);
					}
				}
			}
			prevmouseX = this.mouseX;
			prevmouseY = this.mouseY;
		};
		private function randSet(p_min:Number,p_max:Number):Number {
			return Math.floor(Math.random() * 2);
		}

		//_________________________Public function
		//_________________________Private function
		//_________________________Event
		//_________________________setter getter
	}
	
}