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

flash on 2016-1-11

Get Adobe Flash player
by mutantleg 11 Jan 2016

    Talk

    makc3d at 16 Jan 2016 02:19
    nice toy
    Embed
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ywf8
 */

package {
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
            vecArea = new Vector.<xArea>(0, false);
            
            var a:xArea;
            a = new xArea();
            a.cx = 230; a.cy= 230; a.rad=32;
            vecArea.push(a);
            
          stage.addEventListener(MouseEvent.CLICK, onClick);  
          stage.addEventListener(Event.ENTER_FRAME, onEnter);  
        }//ctor
        
        public function onClick(e:MouseEvent):void { mbutton = 2; }
        
        public var mbutton:int = 0;
        
        public var vecArea:Vector.<xArea>;
        
        public function getMag(ax:Number, ay:Number):Number  { return Math.sqrt(ax*ax+ay*ay); }
        
        public function getArea(ax:Number, ay:Number, dist:Number):xArea
        {
            var ret:xArea; var d:Number;
            var i:int; var a:xArea; var num:int;
            num = vecArea.length; ret =null;
            for(i=0;i<num;i+=1)
            {
              a = vecArea[i];
              d = getMag(ax-a.cx, ay-a.cy);
              if (d >dist) { continue;}
              dist = d;
              ret = a;
            }//nexti            
           return ret;     
        }//getarea
        
    
      public function onEnter(e:Event):void
      {
       graphics.clear();
       graphics.lineStyle(2, 0);
 
        var mx:Number; var my:Number;
        mx = stage.mouseX; my = stage.mouseY;
        
        a = getArea(mx,my, 64);
        
        if (a != null)
        {
          
          if (getMag(a.cx-mx,a.cy-my) < 12) { mbutton=0; }
          else
          { graphics.moveTo(a.cx,a.cy);    graphics.lineTo(mx,my);    }
 
          if (mbutton > 0) 
          {
            var b:xArea;
            b = new xArea(); 
            b.cx=mx; b.cy=my; b.rad = 64;
            b.parent = a;
            vecArea.push(b);  
          }//endif
            
        }//endif
        mbutton = 0;
         
        var i:int; var a:xArea; var num:int;
        num = vecArea.length;
        for(i=0;i<num;i+=1)
        {
          a = vecArea[i];
         graphics.lineStyle(2, 0); 
          graphics.drawCircle(a.cx,a.cy,8);
          
          if (a.parent != null)
          {
            graphics.moveTo(a.cx, a.cy);
            graphics.lineTo(a.parent.cx, a.parent.cy);  
          }//endif
          
         graphics.lineStyle(1, 0x808080); 
          graphics.drawCircle(a.cx, a.cy, a.rad);
          
          
        }//nexti
          
      }//onenter    
        
    }//classend
}

internal class xArea
{
  public var cx:Number = 0;
  public var cy:Number = 0;
  public var rad:Number = 0;  

  public var parent:xArea = null;
 
}//xarea