topical media & game development

talk show tell print

animation-ch05-Velocity2.ax

animation-ch05-Velocity2.ax [swf] [flash] flex


  package
  {
          import flash.display.Sprite;
          import flash.events.Event;
          
          public class @ax-animation-ch05-Velocity2 extends Sprite
          {
                  private var ball:animation_ch05_Ball;
                  private var vx:Number = 5;
                  private var vy:Number = 5;
                  
                  public function @ax-animation-ch05-Velocity2()
                  {
                          init();
                  }
                  
                  private function init():void
                  {
                          ball = new animation_ch05_Ball();
                          addChild(ball);
                          ball.x = 50;
                          ball.y = 100;
                          addEventListener(Event.ENTER_FRAME, onEnterFrame);
                  }
                  private function onEnterFrame(event:Event):void
                  {
                          ball.x += vx;
                          ball.y += vy;
                  }
          }
  }
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.