1 Reply Latest reply on Jun 18, 2008 2:36 PM by Newsgroup_User

    How Do You Stop a Function (k)

    Level 7
      I have this code placed in the second frame of my timeline. It is there
      to pause the playhead for 4 seconds before moving onto the next frame.

      Problem with the code is that once the statement is true it keeps
      jumping ahead doing a perpetual nextFrame.

      I want to reset the variables and stop the function. I have no idea what
      I am doing.

      //
      startTime = getTimer();
      trace("startTime "+startTime);
      this.onEnterFrame = function() {
      currentTime = getTimer();
      //4000 below = 4 seconds
      if (currentTime-startTime>4000) {
      nextFrame();
      trace("currentTime "+currentTime);
      }
      };
        • 1. Re: How Do You Stop a Function (k)
          Level 7
          Figured it out:


          stop();
          //
          startTime = getTimer();
          this.onEnterFrame = function() {
          currentTime = getTimer();
          //4000 below = 4 seconds
          if (currentTime-startTime>4000) {
          nextFrame();
          this.onEnterFrame = null;
          }
          };








          W. Kirk Lutz wrote:
          > I have this code placed in the second frame of my timeline. It is there
          > to pause the playhead for 4 seconds before moving onto the next frame.
          >
          > Problem with the code is that once the statement is true it keeps
          > jumping ahead doing a perpetual nextFrame.
          >
          > I want to reset the variables and stop the function. I have no idea what
          > I am doing.
          >
          > //
          > startTime = getTimer();
          > trace("startTime "+startTime);
          > this.onEnterFrame = function() {
          > currentTime = getTimer();
          > //4000 below = 4 seconds
          > if (currentTime-startTime>4000) {
          > nextFrame();
          > trace("currentTime "+currentTime);
          > }
          > };