clearInterval not working
- Started
- Last post
- 8 Responses
- CyBrain
Help please. (AS2)
What on earth could possibly be preventing this interval from being cleared:randomWait = function() {
clearInterval(rwId);
gotoAndPlay("steam");
}
delaySteam = function() {
rwId = setInterval(randomWait, randomDelay);
}
- CyBrain0
forgot to post the first line:
var randomDelay:Number = (Math.random() * 1.0 + 0.5) * 1000;
- bulletfactory0
could it be that it's working and the time is just too short for frame-based animations?
put some trace("something happening now"); actions in to see where it's hanging up.
- CyBrain0
I had a trace inside the randomWait function that kept repeating roughly every 1 second. That's how I know the interval isn't clearing. Since the numbers being generated are all at least 500 milliseconds, it's not a frame rate issue.
- CyBrain0
The value randomDelay only gets set once, just to delay the framehead that long. Then the interval should get cleared after the goto statement.
- pylon0
Is your SWF getting called into another SWF? We've had massive problems with setInterval in that scenario...
... or maybe it's to do with the random number, as PB suggests?
- CyBrain0
It will be called into another movie eventually, but I'm testing it on its own right now. Unfortunately, I gave up and faked some randomness on the timeline. I'm content with my potato steam and I'm moving on. Thanks for all the help everyone.
- PonyBoy0
just for giggles... did you try making the interval global?...
_global.myInterval = setInterval...
clearInterval(_global.myInterval...