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

spider line

Get Adobe Flash player
by IPFix 13 Oct 2010
/**
 * Copyright IPFix ( http://wonderfl.net/user/IPFix )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/neD6
 */

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    public class FlashTest extends Sprite {
        private var points:Array = new Array();
        private var lastX:Number = stage.mouseX;
        private var lastY:Number = stage.mouseY;
        private var maxDist:uint = 45;
        
        public function FlashTest() {            
            //call mouseMoveHandler when mouse move
            stage.addEventListener( MouseEvent.MOUSE_MOVE, mouseMoveHandler );
        }
        
        private function mouseMoveHandler(e:MouseEvent):void {
            graphics.lineStyle( 1, 0, 0.3 );
            if( lastX != mouseX || lastY != mouseY ) {
                graphics.moveTo(lastX,lastY);
                graphics.lineTo(e.stageX,e.stageY);
                points.push( {x:e.stageX, y:e.stageY} );
                lastX = e.stageX;
                lastY = e.stageY;
                        
                for( var i:int = 0; i < points.length; i++ ) {
                     if( dist(points[i].x,points[i].y,lastX,lastY) < maxDist ){
                          graphics.moveTo(lastX,lastY);
                          graphics.lineTo(points[i].x,points[i].y);
                    }
                }
                        
           }
           graphics.endFill();
        }
            
        //Calcule de la distance type manhattan
        private function dist(x1:Number,y1:Number,x2:Number,y2:Number):Number {
            return Math.abs(x1-x2)+Math.abs(y1-y2);
        }
    }
}