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 2015-9-25

Get Adobe Flash player
by mutantleg 25 Sep 2015
    Embed
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/uFQO
 */

package {
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
         
             vec = new Vector.<xRect>(0, false);
         
             var a:xRect;
             var i:int; var k:int;
             var ax:Number; var ay:Number;
             ax = 64; ay = 64;
             
             for (i=0;i<16;i+=1)
             {
               for (k = 0; k < 16; k+=1)
               {
                   a = new xRect(); vec.push(a); 
                   a.col = 0x80;
                   a.cx = ax+ k * 16;    
                   a.cy = ay+ i * 16;
                   a.cw =  a.ch = 16;
                   a.maxx = 64;
                  
                 
               }//nextk  
             }//nexti
         
             for (i=0;i<8;i+=1)
             {
               for (k = 0; k < 8; k+=1)
               {
                
                   a = new xRect(); vec.push(a); 
                   a.col = 0x8000;
                   a.cx = ax+ k * 32;    
                   a.cy = ay+ i * 32;
                   a.cw =  a.ch = 32;
                   a.minx = 64;
                   a.maxx= 128;

               }//nextk  
             }//nexti
            
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
        
        public var vec:Vector.<xRect>;
        
        public function getDist(ax:Number, ay:Number):Number
        { return Math.sqrt(ax*ax + ay*ay); }
        
        public function getDist2(ax:Number, ay:Number):Number
        { ax=ax<0?-ax:ax; ay=ay<0?-ay:ay; return ax>ay?ax:ay; }
        
        public function onEnter(e:Event):void
        {
            
            
            graphics.clear();
            graphics.lineStyle(1, 0);
            
            var mx:Number; var my:Number;
              
              mx = stage.mouseX; my = stage.mouseY;
                        
              mx = Math.floor(mx/16)*16;
              my = Math.floor(my/16)*16;
                        
                        
              graphics.drawCircle(mx,my, 64);          
              
                        
            var ax:Number; var ay:Number;
            var i:int; var num:int; var a:xRect;
            var d:Number;
            num = vec.length;
            for (i=0;i<num;i+=1)
            {
               a = vec[i];
               ax = a.cx + a.cw *0.5;
               ay = a.cy + a.ch * 0.5;
               
                 graphics.drawRect(a.cx,a.cy,a.cw,a.ch);   
                
               //if (getDist(mx-ax,my-ay)>64) { continue; }
             //  if (getDist2(mx-ax,my-ay) > 64) { continue; }
                d =getDist2(mx-ax,my-ay); 
                //d = getDist(mx-ax,my-ay);
               if (d > a.maxx) { continue; }
               if (d < a.minx) { continue; }
               
               graphics.beginFill(a.col, 0.5);
                 graphics.drawRect(a.cx,a.cy,a.cw,a.ch);   
               graphics.endFill();
                
            }//nexti
            
        }//onenter
        
        
    }//classend
}

internal class xRect
{
   public var cx:Number = 0;
   public var cy:Number = 0;
   public var cw:Number = 0;
   public var ch:Number = 0; 
    
   public var col:uint = 0;
    
   public var maxx:Number = 64; 
   public var minx:Number = 0;
    
}//xrect