3 Replies Latest reply on Feb 9, 2008 8:44 AM by robdillon

    gotoAndPlay instead stops

      I have a script within a frame that initiates a stop, a time delay, and then a gotoAndPlay () - See attached code. That all works great! However, when I gotoAndPlay (2) it just stops in frame 2 rather than playing from that point. In fact I can nicely go to any Frame I want - as long as I want to just stop there. There are no other scripts or hidden stop () commands lurking anywhere. Its a very clean and open timeline. Whats the deal?
      Any help - greatly appreciated.
        • 1. Re: gotoAndPlay instead stops
          robdillon Most Valuable Participant
          You have an onEnterFrame function that is running continuously, even after you think you've finished with it. So, what is happening is that when the if condition returns true the first time, the playback head will jump forward to frame 2. However, the onEnterFrame function will continue to run. And the if condition will still be true, and so the playback head will get pulled back to frame 2, over and over, and over...

          What you want to do is to kill the onEnterFrame function when you are finished with it. You can do that by putting "delete onEnterFrame" after the gotoAndPlay(2); line.

          Alternately, you could use a setInterval function and then use clearInterval to remove the event.
          • 2. Re: gotoAndPlay instead stops
            smdevivo5359 Level 1
            Thanks very much... that worked well - See attached code - and it fixed the initial problem. But now I've created another small problem. After I initiate a CONTINUE out of that particular loop, if the next sequence in the timeline takes longer than 2000 to reach the next set of frame instructions, it kicks everything back to the original frame. Hope Im being clear on that.
            In other words it appears as though my timer resets and counts again and again.
            How do I make it count once and then kill it?
            Is this where clearInterval can come into play/ If so how do I set it up?
            Thanks again!
            • 3. Re: gotoAndPlay instead stops
              robdillon Most Valuable Participant
              There's nothing wrong with your code. If your movie is looping back to some previous frame then something else is wrong. If Flash, before CS3, encounters a goto action that it can't resolve, it will send the playback head back to the first frame in the local timeline.

              The setInterval alternative to enterFrame loop looks like this: