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-6-12

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

package {
    import flash.ui.Keyboard;
    import flash.events.KeyboardEvent;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
            stage.addEventListener(KeyboardEvent.KEY_DOWN, onKdown);
            stage.addEventListener(KeyboardEvent.KEY_UP, onKup);
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
        
        public var vecKey:Vector.<Boolean> = new Vector.<Boolean>(512,false);
        public function onKdown(e:KeyboardEvent):void { vecKey[e.keyCode] = true; }
        public function onKup(e:KeyboardEvent):void { vecKey[e.keyCode] = false; }
        public function isKey(k:int):Boolean { return vecKey[k]; }
        
        public var cx:Number = 235;
        public var cy:Number = 235;
        public var mode:int = 0;
        public var wait:int = 0;
        public var gx:Number =0;
        public var gy:Number=0;
       

        public function isOver(ax:Number,ay:Number,aw:Number,ah:Number):Boolean
       { graphics.drawRect(ax,ay,aw,ah);        
         if (wait>0) { graphics.drawRect(ax-Math.random()*2,ay-Math.random()*2,aw+Math.random()*4,ah+Math.random()*4); }
         return (cx<ax||cx>ax+aw||cy<ay||cy>ay+ah)==false; }
      
       public function onEnter(e:Event):void
       {
           graphics.clear();
           graphics.lineStyle(2, 0);
           
           var ms:Number; ms = 8;
           if (wait>0){ms=0;}
           if (isKey(Keyboard.UP)) { cy-=ms;}
           if (isKey(Keyboard.DOWN)) { cy+=ms;}
           if (isKey(Keyboard.LEFT)) { cx-=ms;}
           if (isKey(Keyboard.RIGHT)) { cx+=ms;}
           
           
           if (wait>0)
           { wait-=1; if (wait<=0){cx=gx;cy=gy; }}
           
           if (wait<=0) { graphics.drawCircle(cx,cy,16); }
           
           var k:int; k = 0;
           if (isOver(132,235,32,32) ) { k =1;  if (mode==0) { mode=1; gx=332+16; gy=235+16; wait=10; } }
           if (isOver(332,235,32,32) ) { k =1;  if (mode==0) { mode=1; gx=132+16; gy=235+16; wait=10; } }
           mode=k;
          
          
           
           
       }//onenter  
        
    }//classend
}