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

Get Adobe Flash player
by mutantleg 26 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/gPpT
 */

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 var cx:Number = 80;
        public var cy:Number = 80;
        public var cw:Number = 160;
        public var ch:Number = 160;
        
        public function isOver(ax:Number,ay:Number, aw:Number,ah:Number,  
            bx:Number,by:Number, bw:Number,bh:Number):Boolean
        {
          if (ax+aw < bx) { return false; }  
          if (ay+ah < by) { return false; }  
          if (bx+bw < ax) { return false; }  
          if (by+bh < ay) { return false; }  
          
         return true;            
        }//isover
        
        
        public function onEnter(e:Event):void
        {
            var mx:Number; var my:Number;
            var ax:Number; var ay:Number;
            var aw:Number; var ah:Number;
            
            graphics.clear();
            graphics.lineStyle(2, 0);
            
            mx = stage.mouseX; my = stage.mouseY;
            graphics.drawCircle(mx,my, 8);
            
            var ms:Number;
            ms = 64;
            ax = mx - ms; ay = my -ms;
            aw = ms*2; ah = ms*2;
            
            graphics.drawRect(ax,ay,aw,ah);




                var k:int;
                for (k =0; k<4;k+=1)
                {
                    cx = 80; cy = 80;
                    if (k==1){cx += cw; }
                    if (k==2){cy += ch; }
                    if (k==3){cx += cw; cy+=ch; }
                    
                     graphics.drawRect(cx,cy,cw,ch);
                     if (isOver(ax-128,ay-128,aw+256,ah+256, cx,cy,cw,ch) == false) { continue; }
                   
                         var bx:Number; var by:Number;
                         var bw:Number; var bh:Number;
                         bw = cw*0.5; bh = ch*0.5;
                         
                         var i:int;
                         
                         for (i=0;i<4;i+=1)
                         {
                           bx = cx; by =cy;
                           if (i==1) {bx+=bw; }
                           else if (i==2) {by+=bh; }
                           else if (i==3) {bx+=bw; by+=bh; }
                           
                           if (isOver(ax,ay,aw,ah, bx,by,bw,bh) == false) 
                           { 
                            graphics.beginFill(0, 0.5);               
                             graphics.drawRect(bx,by, bw,bh);  
                            graphics.endFill();
                             continue;
                           }//endif
                           
                                  graphics.beginFill(0, 0.4);               
                                     graphics.drawRect(bx,by,bw*0.5, bh*0.5);
                                     graphics.drawRect(bx+bw*0.5,by+bh*0.5,bw*0.5, bh*0.5);
                                  graphics.endFill();
                  
                     }//nexti             
            
            
                }//nextk
                
        }//onenter
        
        
    }//classned
}