Problems getting the getTimer function to work properly

Hello:

I am looping between 2 frames using getTimer in conjunction with gotoAndPlay - see attached code.
Basically, the timeline travels to Frame 20, pauses for 2 seconds, then goes back to Frame 1 and plays again.  And that process repeats over and over again unless the user hits a Continue button on the stage to then move to another area of the timeline.  That part is working perfectly.

The problem occurs if the next loop takes longer than 2 seconds.  In other words instead of going from Frame 1 to 20, the next sequence might go from Frame 21 to 100.  Before it makes it to Frame 100 the previous getTimer process takes control and sends me all the way back to Frame 1.

In my limited experience with Flash AS2, it appears as though the previous timer is still running and each time it clicks off 2 seconds, it performs the previous gotoAndPlay (1).  In other areas of the timeline, where the the Point A to B is quick within the timeline, this problem never occurs.

Hope I explained that all clearly.  Any help would be greatly appreciated.

Steve
stop();
timeDelay = getTimer()+2000;
onEnterFrame = function(){
if (this.timeDelay <= getTimer()){
gotoAndPlay(1);
delete onEnterFrame;
}
}

Open in new window

smdevivoAsked:
Who is Participating?
 
ZefferConnect With a Mentor Commented:
try this..

stop();
timeDelay = getTimer()+2000;
onEnterFrame = function(){
if (this.timeDelay <= getTimer()){
gotoAndPlay(1);
delete onEnterFrame;
}
else if( this._currentframe >20){
delete onEnterFrame;
}
}

Z
0
 
smdevivoAuthor Commented:
Just one little line of code - but it means the world to me.  Thanks, you helped me out immensely.  Everything now runs perfectly and I can meet the deadline.
0
All Courses

From novice to tech pro — start learning today.