Velocity Animation : Velocity « Animation « Flash / Flex / ActionScript






Velocity Animation

 

package {
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class Main extends Sprite {
        private var _sprite:Sprite = new Sprite(  );
        
        public function Main(  ) {
            _sprite.graphics.beginFill(0x0000ff, 100);
            _sprite.graphics.drawCircle(0, 0, 25);
            _sprite.graphics.endFill(  );
            _sprite.x = 50;
            _sprite.y = 10;
            addChild(_sprite);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        public function onEnterFrame(event:Event):void {
        _sprite.x += 1;
        _sprite.y += 2;
        }
    }    
}

        








Related examples in the same category

1.Calculating position based on velocity
2.Change speed direction after hitting the boundary