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-2-28

Get Adobe Flash player
by mutantleg 28 Feb 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/k1ld
 */

package {
    import flash.display.BitmapData;
    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:int = 3;
        public var cy:int = 2;
        public var wx:int = 1;
        public var wy:int = 0;
        
        public var cw:Number = 32;
        public var ch:Number = 32;
        
        public var mw:int = 8;
        public var mh:int = 8;
        
        public var rx:int = 3;
        public var ry:int = 3;
        public var rw:int = 2;
        public var rh:int = 2;
        
        public function isWall(ax:Number, ay:Number):Boolean
        {
           if ((ax < rx || ay < ry || ax >= rx+rw || ay >= ry+rh)==false) { return true; } 
           if (ax < 0) { return true; }      if (ay < 0) { return true; }
           if (ax >= mw) { return true; }    if (ay >= mh) { return true; }
           return false;
        }//iswall
        
        public var gt:int = 0;
        
        public function onEnter(e:Event):void
        {
          gt+= 1; 
          if (gt % 8 != 0) { return; }  
          
          graphics.clear();
          graphics.lineStyle(2, 0);  
            
          graphics.drawRect(0,0,mw*cw,mh*ch);  
          graphics.drawRect(cx*cw,cy*ch, cw,ch);  
          
          graphics.moveTo(cx*cw+cw*0.5,cy*ch+ch*0.5);
          graphics.lineTo(cx*cw+cw*0.5+wx*cw,cy*ch+ch*0.5+wy*ch);
          
          graphics.lineStyle(2,0xFF0000);
          graphics.moveTo(cx*cw+cw*0.5,cy*ch+ch*0.5);
          graphics.lineTo(cx*cw+cw*0.5+wy*-cw,cy*ch+ch*0.5+wx*ch);
          
         graphics.lineStyle(2, 0);
         graphics.drawRect(rx*cw, ry*ch, rw*cw, rh*ch);         
          
          var t:int;
          
          if (isWall(cx+wx,cy+wy))          { t = wx; wx = -wy; wy = t;  }      
          if (isWall(cx-wy,cy+wx) ==false)  { t = wx; wx = -wy; wy = t;  }
          cx += wx;       cy += wy;  
            
           
        }//onenter
        
    }//classend
}