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

forked from: forked from: Connect The Dots

/**
 * Copyright y_nk_ ( http://wonderfl.net/user/y_nk_ )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/cbfh
 */

// forked from Altschuler's forked from: Connect The Dots
// forked from shapevent's Connect The Dots
package {

    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;


    [SWF(width = 500, height = 500)]

       public class ConnectTheDots extends MovieClip {
        private const TWO_PI:Number =  Math.PI * 2;
        private var centerX:Number;
        private var centerY:Number;
        private var offset : Number;


               public function ConnectTheDots(){
                  // init
            centerX = stage.stageWidth / 2;
            centerY = stage.stageHeight / 2;
            offset = 0;
            addEventListener(Event.ENTER_FRAME, onLoop);
            

               }
               // private methods

        private function onLoop(evt:Event):void{
            // data
            var points:Array = [];
            var i:int = 0;
            var pointNum : int = Math.max(2,int(mouseX / 12))
            
            var radius:Number = 600;
            var step:Number = TWO_PI / pointNum;
            var theta:Number = step / 2;
            offset+=.1;
            for (i = 0; i<pointNum; i++){
                var xp:Number = centerX + (radius+Math.cos(i+offset)*(mouseY/20)) * Math.cos(theta);
                var yp:Number = centerY + (radius+Math.sin(i+offset)*(mouseY/20)) * Math.sin(theta);
                points[i] = new Point(xp, yp);
                theta += step;
            }
            // render
            graphics.clear();
            graphics.lineStyle(0,0);
            for ( i = 0; i<pointNum; i++){
             var a:Point = points[i];
             for (var j:int = 0; j<pointNum; j++){
                var b:Point = points[j];
                if (a != b){
                   graphics.drawCircle(a.x, a.y, 10);
                   graphics.moveTo(a.x, a.y);
                   graphics.lineTo(b.x, b.y);
                }
             }
           }
        }
       }
}