1 Reply Latest reply on Jul 21, 2011 5:28 AM by Ned Murphy

    Problem with hitTest and gotoAndPlay

    lvl5accelerator

      I have three symbols.

       

      First is a Shield MovieClip, where in the first frame I have placed a stop(); Action and the second frame is where the animation starts..

       

      Second is a Ship and third is a PowerUp.

       

      Inside the Ship symbol, I placed the Shield MovieClip. I wanted to create a hitTest when the Ship hits the PowerUp, the Shield MovieClip inside of the Ship will start playing.

       

      This is my code that doesn't work:

       

      if(this.hitTest(_root.ship))
                  {
                      _root.Ship.Shield.gotoAndPlay(2);

                  }

       

      Any help or suggestions is much appreciated!

        • 1. Re: Problem with hitTest and gotoAndPlay
          Ned Murphy Adobe Community Professional & MVP

          To use that type of test you need to continually execute it, otherwise it just checks the first time the code is encountered an not again.  Look into using something like... though it is not clear how/where you have that code implemented, so it might have to change slightly from what is shown.

           

          this.onEnterFrame = testForHit;

           

          function testForHit(){

              if(this.hitTest(_root.ship))
              {
                    delete this.onEnterFrame;

                    _root.Ship.Shield.gotoAndPlay(2);

              }

          }

          1 person found this helpful