topical media & game development

talk show tell print

lib-flex-animation-code-06-VerletPointTest.ax

lib-flex-animation-code-06-VerletPointTest.ax (swf ) [ flash ] flex


  package {
          import flash.display.Sprite;
          import flash.display.StageAlign;
          import flash.display.StageScaleMode;
          import flash.events.Event;
          import flash.geom.Rectangle;
  
          public class @ax-lib-flex-animation-code-06-VerletPointTest extends Sprite
          {
                  private var _point:VerletPoint;
                  private var _stageRect:Rectangle;
                  
                  public function @ax-lib-flex-animation-code-06-VerletPointTest()
                  {
                          stage.align = StageAlign.TOP_LEFT;
                          stage.scaleMode = StageScaleMode.NO_SCALE;
                          _stageRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
                          
                          _point = new VerletPoint(100, 100);
                          _point.x += 5;
                          addEventListener(Event.ENTER_FRAME, onEnterFrame);
                  }
                  
                  private function onEnterFrame(event:Event):void
                  {
                          _point.y += .5;
                          _point.constrain(_stageRect);
                          _point.update();
                          
                          graphics.clear();
                          _point.render(graphics);
                  }
          }
  }
  


(C) Æliens 18/6/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.