Skip to main content
Inspiring
June 18, 2008
Question

How Do You Stop a Function (k)

  • June 18, 2008
  • 1 reply
  • 212 views
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);
}
};
This topic has been closed for replies.

1 reply

Inspiring
June 18, 2008
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);
> }
> };