2 Replies Latest reply on Sep 8, 2010 6:29 AM by Ned Murphy

    gotoAndplay on hitTest?


      I'm trying to make it so that when a movieclip (box) touches another movieclip (exit), it goes to frame 2.


      I've made it so that (box) moves with the arrow keys and doesn't go pat the barriers (boulders) using this:



      box.onEnterFrame = function()


      if (Key.isDown(Key.RIGHT)) {box._x += 5;}

      if (Key.isDown(Key.LEFT)) {box._x -= 5;}

      if (Key.isDown(Key.UP)) {box._y -= 5;}

      if (Key.isDown(Key.DOWN)) {box._y += 5;}

      if (box.hitTest(boulderRight)) {box._x -=5;}

      if (box.hitTest(boulderLeft)) {box._x +=5;}

      if (box.hitTest(boulderUp)) {box._y += 5;}

      if (box.hitTest(boulderDown)) {box._y -= 5;}



      However, when I add this:


      if(box.hitTest (exit)) {this.gotoAndplay("2");}


      It doesn't work, and (box) simply passes through (exit) with nothing happening.



      If I use dynamic text I can make it so it says "Use the Arrow Keys to move" to begin with, then "Congratulations" when (box) touches (exit) using this:


      onClipEvent (enterFrame)


      if (_root.box, hitTest(_root.exit)) {_root.text = "Congratulations!";}

      else {_root.text = "Use the Arrow Keys to move";}



      But I can't seem to get it to gotoAndPlay at frame 2.


      Any help would be appreciated.


      I am using Macromedia Flash MX2004 and Actionscript 2.0.