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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZefferCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.