flash on 2011-7-30

by yd_niku
♥0 | Line 33 | Modified 2011-07-30 13:54:50 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.*;
    import flash.events.*;
    public class FlashTest extends Sprite {
        
        public var ball:Sprite;
        
        public var mass:Number = 4;
        public var vx:Number = 0;
        public var vy:Number = 0;
        public var mousex:Number = 0;
        public function FlashTest() {
            // write as3 code here..
            ball = new Ball();
            addChild(ball);
            ball.x = 200;
            ball.y = 10;
            
            vx = 0;
            vy = 0.98;
            
            addEventListener(Event.ENTER_FRAME,loop);
        }
        private function loop(e:Event):void{
            
            mousex = (mouseX-230)/230;
            
            ball.x += mass*(vx + mousex);
            ball.y += mass*(vy);
        
        }
    }
}


import flash.display.*;

class Ball extends Sprite{
    public function Ball(){
        graphics.beginFill(0x000066);
        graphics.drawCircle(0,0,20);
        graphics.endFill();
    }
}