topical media & game development

talk show tell print

animation-ch09-PointHitTest.ax

animation-ch09-PointHitTest.ax [swf] [flash] flex


  package
  {
          import flash.display.Sprite;
          import flash.events.Event;
          
          public class @ax-animation-ch09-PointHitTest extends Sprite
          {
                  private var ball:animation_ch09_Ball;
                  
                  public function @ax-animation-ch09-PointHitTest()
                  {
                          init();
                  }
                  
                  private function init():void
                  {
                          ball = new animation_ch09_Ball();
                          addChild(ball);
                          ball.x = stage.stageWidth / 2;
                          ball.y = stage.stageHeight / 2;
                          
                          addEventListener(Event.ENTER_FRAME, onEnterFrame);                        
                  }
                  
                  private function onEnterFrame(event:Event):void
                  {
                          if(ball.hitTestPoint(mouseX, mouseY))
                          {
                                  trace("hit");
                          }
                  }
          }
  }
  


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