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

wireFall

click and pull mouse button on screen and wires will fall out of your pointer

made by me
yakir13@gmail.com
Get Adobe Flash player
by yAKIr 02 Apr 2011
/**
 * Copyright yAKIr ( http://wonderfl.net/user/yAKIr )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/s3Be
 */

///////////////////////
// made by me        //
// yakir13@gmail.com //
///////////////////////
package {
    import flash.display.*;
    import flash.events.*;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            stage.quality = StageQuality.LOW;
            var bg:Shape = new Shape();
            var screen:Shape = new Shape();
          
            bg.graphics.beginFill(0x000000);
            bg.graphics.moveTo(0, 0);
            bg.graphics.lineTo(stage.stageWidth, 0);
            bg.graphics.lineTo(stage.stageWidth, stage.stageHeight);
            bg.graphics.lineTo(0, stage.stageHeight);
            bg.graphics.lineTo(0, 0);
            bg.graphics.endFill();
            
            var bmd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x00ffffff);
            var bm:Bitmap  = new Bitmap(bmd);
            this.addChild(bm);
            
            var heads:Array = [];
            var wires:Array = [];
            var wiresLengths:Array = [];
            var wiresColors:Array = [];
            var wirelength:int = 0;
            var wireRelease:Boolean = false;
            
            addEventListener(Event.ENTER_FRAME,enter_frame);
            function enter_frame(event:Event):void
            {
                var i:int = 0;
                wirelength++;
                for (var head:String in heads)
                {
                    heads[head].X +=  heads[head].speedX;
		    heads[head].Y +=  heads[head].speedY;
		    heads[head].speedY +=  0.2;
                    if (heads[head].Y > stage.stageHeight)
		    {
			heads[head].Y = stage.stageHeight;
			heads[head].speedY *=  -(Math.random()*0.5+0.5);
		    }
                    if (heads[head].X > stage.stageWidth)
		    {
			heads[head].X = stage.stageWidth;
			heads[head].speedX *=  -(Math.random()*0.5+0.5);
		    }
                    if (heads[head].X < 0)
		    {
			heads[head].X = 0;
			heads[head].speedX *=  -(Math.random()*0.5+0.5);
		    }
                    wires[head].push({X:heads[head].X, Y:heads[head].Y});
                    if (wires[head].length > wiresLengths[head])
		    {
			wires[head].splice(0, 1);
		    }
                    if (Math.abs(heads[head].speedX) < 1)
		    {
			if (heads[head].speedY > 0 && heads[head].speedY < 1 && heads[head].Y > stage.stageHeight - 10)
			{

			    heads.splice(head, 1);
			    wires.splice(head, 1);
			    wiresLengths.splice(head, 1);
                            wiresColors.splice(head, 1);
			}
		    }
                }
                screen.graphics.clear();
                
                for (var wire:String in wires)
	            {
                    screen.graphics.lineStyle(1, wiresColors[wire], 1);
		    screen.graphics.moveTo(wires[wire][0].X, wires[wire][0].Y);
		    for (var line:String in wires[wire])
		    {
			screen.graphics.lineTo(wires[wire][line].X, wires[wire][line].Y);
		    }
	        }
                bmd.fillRect(bmd.rect, 0);
                bmd.draw(bg);
	        bmd.draw(screen);
            }
            
            var hold:Boolean=false;
            var wirecount:int=0;
            stage.addEventListener(MouseEvent.MOUSE_DOWN, mouse_down);
            function mouse_down(event:Event):void
            {
                hold = true;
	        wirelength = 0;
            }
            stage.addEventListener(MouseEvent.MOUSE_UP, mouse_up);
            function mouse_up(event:Event):void
            {
                hold = false;
	        for (var a:int=0; a<wirecount+1; a++){
		    wiresLengths.push(wirelength);
	        }
	        wirecount=0;
            }
            
            var preMouseX:Number=0;
            var preMouseY:Number=0;
            stage.addEventListener(MouseEvent.MOUSE_MOVE, mouse_move);
            function mouse_move(event:Event):void
            {
                if (hold)
	        {
		    wirecount++;		
		    heads.push({X: mouseX, Y:mouseY, speedX: mouseX-preMouseX, speedY:mouseY-preMouseY});
		    wires.push(new Array());
		    wires[wires.length - 1].push({X:heads[heads.length-1].X, Y:heads[heads.length-1].Y});
                    wiresColors.push(Math.round(Math.random() * 0xFFFFFF));
	        }
                preMouseX=mouseX;
	        preMouseY=mouseY;
            }
        }
    }
}