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

FF: flash on 2016-1-19

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

// forked from mutantleg's flash on 2016-1-19
package {
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.display.Graphics;
    public class FlashTest extends Sprite {
        
        private const G_LINE_THIKNESS:Number = 1;
        private const G_FILL_COLOR:uint = 0x40A540;
        private const G_POINT_RADIUS:Number = 3;
        
        private const G_S:int = 16;
        private const G_X:int = 24;
        private const G_Y:int = 24;
        
        private const G_POS_X:Number = 40;
        private const G_POS_Y:Number = 40;
        
        private var C_CANVAS:Graphics;
        
        public function FlashTest() {
            graphics.beginFill( 0xE3F3E3 );
            graphics.drawRect( 0,0,465,465);
            C_CANVAS = ( stage.addChild( new Shape() ) as Shape ).graphics;
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
            stage.addEventListener('rightMouseDown', function(e:*):void{});
        }//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;

           C_CANVAS.clear();
           C_CANVAS.lineStyle(G_LINE_THIKNESS, 0, 0.4); 
           
           mx = stage.mouseX; my = stage.mouseY;
           C_CANVAS.drawCircle(mx,my,G_S);
           C_CANVAS.drawCircle(mx,my,G_S<<1);
            
           rw=G_S; rh=G_S;
           for (i=0;i<G_Y;i+=1)
           {
             for (k=0;k<G_X;k+=1)
             {  
              rx = k*rw + G_POS_X;
              ry = i*rh + G_POS_Y;
              d = getDist(mx,my, rx,ry,rw,rh);
              //d = getDist2(mx,my, rx,ry,rw,rh);
              C_CANVAS.drawRect(rx,ry,rw,rh); 
              d = 1 - (d / (G_S<<4));
              ms = 0.25; //0.1; //0.25;
              d = Math.floor(d/ms)*ms;
              if (d<0) { d = 0;}
              //if (d < (G_S<<1)) 
              {
                C_CANVAS.beginFill(G_FILL_COLOR, d);
                 C_CANVAS.drawRect(rx,ry,rw,rh);
                C_CANVAS.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; }
            C_CANVAS.drawCircle(ix,iy,G_POINT_RADIUS);
            ix = ax-ix;
            iy = ay-iy;
            return Math.sqrt(ix*ix+iy*iy);
        }//getdist
        
          
        
    }//classend
}