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

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

package {
    import flash.display.BitmapData;
    import flash.ui.Keyboard;
    import flash.events.KeyboardEvent;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
            skin = new BitmapData(465,465,false,0xFF);
            var i:int;
            for(i=0;i<64;i+=1)
            {
               graphics.beginFill(0xFFffFF,1);
                graphics.drawCircle(465*Math.random(),465*Math.random(),20+32*Math.random());
               graphics.endFill(); 
               graphics.beginFill(0xFFffFF,1);
                graphics.drawRect(465*Math.random(), 465*Math.random(),8+Math.random()*32,8+Math.random()*8);
               graphics.endFill(); 
               
            }//nexti
            skin.draw(this);
            
            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 gt:int = 0;
        public var vy:Number = 0;
        public var canJump:Boolean = true;
      
      
          public var skin:BitmapData;
      
       public function isWall(ax:Number,ay:Number):Boolean
       { return skin.getPixel(ax,ay) ==0xFF; }
      
      
       public function onEnter(e:Event):void
       {
           graphics.clear();
           graphics.lineStyle(2, 0);
           
           graphics.beginBitmapFill(skin,null,false,false);
            graphics.drawRect(0,0,465,465);
           graphics.endFill();
           
          if (isKey(Keyboard.SHIFT)) { cx=stage.mouseX; cy=stage.mouseY;}
             
           if (gt%2==0) {
               
              
           var kx:Number;var ky:Number;
           var ms:Number; ms = 8;
           var ax:Number; var ay:Number;
           ax=0;ay=0;
        
            //canJump = isWall(cx,cy+8);
        
            if (gt%4==0){ vy +=1; }
           if (isKey(Keyboard.UP)  && canJump) { vy=-5; canJump=false; }
           if (isKey(Keyboard.DOWN)) { ay+=ms;}
           if (isKey(Keyboard.LEFT)) { ax-=ms;}
           if (isKey(Keyboard.RIGHT)) { ax+=ms;}
           
           if (vy<0){ay=-8; if (vy>-2){ay=0;}}
           else if (vy==0) {ay=0;}
           else if (vy>0){ay=8;}
           
           kx = Math.floor(cx/ms)*ms;
           ky = Math.floor(cy/ms)*ms;
          
         //  if (canJump)
         //  {
              // if (isWall(kx+ax,ky+4) && isWall(kx+ax,ky-4-8)==false) { cy-=8; } 
             //  if (isWall(kx+ax,ky+4) && isWall(kx+ax,ky-4-8-8)==false) { cy-=16; } 
             // if (isWall(kx+4+ax,ky+4)) {cy-=16; } 
         //}//endif2
          
              if (vy>2||vy<-2) { canJump=false; }
           
            //   if (cy+ay > 200){ cy=200;ay=0;if(vy>0){vy=0;}}
             //  if (isWall(cx,cy)==false)
               {
                if (isWall(kx,ky+ay) && ay > 0) { cy=ky; ay=0;if(vy>0){vy=0; canJump=true;} }
                if (isWall(kx,ky+ay) && ay < 0) { cy=ky; ay=0;if(vy<0){vy=0;} }
                if (isWall(kx+ax,ky) && ax < 0) { cx=kx; ax=0; }
                if (isWall(kx+ax,ky) && ax > 0) { cx=kx; ax=0; }
               }//endif2
                 
              //if (isWall(kx+4,ky+4) && isWall(kx+4,ky-8) && isWall(kx+4,ky-16)==false) { ky-=8; cy=ky; } 
               if (canJump && isWall(kx+4,ky+4)==false && isWall(kx+4,ky+12)) { ky+=8; }
              //if (isWall(kx+4,ky+4)) {cy-=1;}
           
                cx+=ax; cy+=ay; 
           }//endif
           
           ay = 0; if (vy<0) {ay=vy;}
           graphics.beginFill(0xFFffFF,1);
            graphics.drawCircle(cx,cy+ay,8);
           graphics.endFill();
           
           
           gt+=1;
       }//onenter  
        
    }//classend
}