topical media & game development

talk show tell print

animation-ch10-Rotate1.ax

animation-ch10-Rotate1.ax [swf] [flash] flex


  package
  {
          import flash.display.Sprite;
          import flash.events.Event;
          import flash.display.StageScaleMode;
          import flash.display.StageAlign;
  
          public class @ax-animation-ch10-Rotate1 extends Sprite
          {
                  private var ball:animation_ch10_Ball;
                  private var angle:Number = 0;
                  private var radius:Number = 150;
                  private var vr:Number = .05;
                  
                  public function @ax-animation-ch10-Rotate1()
                  {
                          init();
                  }
                  
                  private function init():void
                  {
                          stage.scaleMode = StageScaleMode.NO_SCALE;
                          stage.align = StageAlign.TOP_LEFT;
                          ball = new animation_ch10_Ball();
                          addChild(ball);
                          addEventListener(Event.ENTER_FRAME, onEnterFrame);
                  }
                  
                  private function onEnterFrame(event:Event):void
                  {
                          trace(x);
                          
                          trace(stage.stageWidth / 2);
                          ball.x = stage.stageWidth / 2 + Math.cos(angle) * radius;
                          trace(ball.x);
                          ball.y = stage.stageHeight / 2 + Math.sin(angle) * radius;
                          angle += vr;
                  }
          }
  }
  


(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.