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-19

Get Adobe Flash player
by mutantleg 19 Jan 2016
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/Q4zi
 */

package {
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
    
        public function onEnter(e:Event):void
        {
           var mx:Number; var my:Number;
           var i:int; var k:int;
           var rx:Number; var ry:Number;
           var rw:Number; var rh:Number;
           var d:Number;
           var ms:Number;

           graphics.clear();
           graphics.lineStyle(2, 0); 
           
           mx = stage.mouseX; my = stage.mouseY;
           graphics.drawCircle(mx,my,32);
           graphics.drawCircle(mx,my,64);
            
           rw=32; rh=32;
           for (i=0;i<8;i+=1)
           {
             for (k=0;k<8;k+=1)
             {  
              rx = k*rw + 32;
              ry = i*rh+32;
              d = getDist(mx,my, rx,ry,rw,rh);
              //d = getDist2(mx,my, rx,ry,rw,rh);
              graphics.drawRect(rx,ry,rw,rh); 
              d = 1 - (d / 256);
              ms = 0.25; //0.1; //0.25;
              d = Math.floor(d/ms)*ms;
              if (d<0) { d = 0;}
             // if (d < 64) 
              {
                graphics.beginFill(0x404040, d);
                 graphics.drawRect(rx,ry,rw,rh);
                graphics.endFill();   
              }
             }//nextk  
           }//nexti 
        }//onenter  

        public function getDist2(ax:Number,ay:Number,
        rx:Number,ry:Number,rw:Number,rh:Number):Number
        {
          rx = rx+rw*0.5;
          ry = ry+rh*0.5;
          ax = ax-rx; ay=ay-ry;
          return Math.sqrt(ax*ax+ay*ay);              
        }//getdist2

        
        public function getDist(ax:Number,ay:Number,
        rx:Number,ry:Number,rw:Number,rh:Number):Number
        {
            var ix:Number; var iy:Number;
            if (ax<rx) { ix = rx; }
            else if (ax>rx+rw) { ix = rx+rw; }
            else { ix = ax; }
            if (ay < ry) { iy = ry; }
            else if (ay>ry+rh) { iy = ry+rh; }
            else { iy = ay; }
            graphics.drawCircle(ix,iy,4);
            ix = ax-ix;
            iy = ay-iy;
            return Math.sqrt(ix*ix+iy*iy);
        }//getdist
        
          
        
    }//classend
}