flash on 2012-5-11

by mutantleg
♥0 | Line 52 | Modified 2012-05-11 21:12:50 | MIT License
play

ActionScript3 source code

/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/1nPd
 */

package {
    import flash.events.Event;
    import flash.display.Graphics;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        
        public var player:Sprite;
        public var px:Number = 200;
        public var py:Number = 200;
        
        public function FlashTest() {
            // write as3 code here..
            
            graphics.clear();
            graphics.lineStyle(2,0);
            graphics.drawCircle(200,200, 100);
            
         //   update();
            
           //graphics.drawCircle(100,100, 100);z
             var g:Graphics;
             player = new Sprite();
             g = player.graphics;
             g.lineStyle(2,0);
             g.beginFill(0xFF0000);
             g.drawRect(-16,-16,16,16);
             addChild(player);
            
            
         //   update();
            
            //onEnter(null);
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
        
        public function update():void
        {
            graphics.drawCircle(100,100, 100);
        }//update
        
        public var vx:Number = 0;
        public var vy:Number = 0;
        
        public function onEnter(e:Event):void
        {
           // var vx:Number, vy:Number;
            
          //  graphics.drawCircle(100,100, 100);
          //  graphics.drawCircle(stage.mouseX, stage.mouseY, 4z);
            
            vx = (this.mouseX - px) * 0.1;
            //vy = (this.mouseY - py) * 0.1;
            vy += 0.5;
           
            
            if (vx > 8) { vx = 8; }
            if (vx < -8) { vx = -8; } 
           // if (vy < -8) { vy = -8; }
           // if (vy > 8) { vy = 8; }
            
            px += vx;
            py += vy;
            if (vy > 0 && py >= 380)
            {
                py = 380; 
                //vy = -vy *0.8;
               // if (vy > -4) { vy = -8; }
               //vy = (this.mouseY - py) * 0.1;
               //if (vy >= 0) { vy = -1; }
               //if (vy < -18) {vy = -18;}
               //todo -- calculate exact vy to reach height
               var wy:Number;
               var wx:Number;
               wx = 0.5;
               for (wy = mouseY; wy < 380; wy += wx) 
               {
                   wx += 0.5;
               }
               vy = -wx - 0.1;
            }//endif
            
            player.x = px;
            player.y = py;
            
        }//update
        
    }//classend
}//package