[MX] setInterval Bug?

Hello,

I’ve been experiencing a problem using setInterval and I’m wondering if any Flash users out there have expierienced it and/or have come across a fix for this problem. Heres a description of the layout/problem:

Flash Movie 1: I have an empty movieclip in this movie that I load Flash Movie 2 into.

Flash Movie 2: Gets loaded into Flash Movie 1 into an empty movieclip. This movie contains a setInterval action that repeats indefinitly.

I open Flash Movie 1, press the button to load Flash Movie 2, Movie 2 performs as expected. The setInterval loop performs correctly.

Next I unload Movie 2 from Movie 1. During the unload I clear the interval thats happening in Movie 2. Now while I’m still in the same session I load Movie 2 back into Movie 1. The setInterval loop seems to be going even faster then before. I unload Movie 2 and repeat - loading it back into Movie 1 and now the setInterval is going even faster.

Yet each time the Interval is cleared. Now if I reset my movie by closing and reopening it the setInterval works fine the first time - but throughout the session as the movie containing it is loaded and unloaded the interval keeps going faster and faster each time.

Is this a bug in Flash MX? Does anyone know of a cure for this?

Thanks :rd:

I’m having the exact same issue. The interval in the loaded swf gets faster and faster even though I have a clearInterval in the loaded swf .

Did you solve this issue?

clear the interval from the movie you are loading into before you load/reload a movie

btn.onPress = function() {
	clearInterval(container.intervalName);
	container.loadMovie("whatever.swf");
};

As a last resort you can just loop through a huge amount of numbers which although not so efficient will work

for (var i = 1; i<1000; i++) {
	clearInterval(i);
}

The latter did the trick. I wouldn’t have thought clearing the Interval on the main timeline would have worked. Thanks a ton…you saved me a lot of grief.

I am struggeling with the same problem, but that last didn’t work for me. you just placed that in the main time line as a framscript?

Just stick it in a function and call the function whenever you need.If you have only used a couple of intervals in your external movie would be better to clear each individually.This is only a last resort solution.

dnx 2 da dude “stringy”!!!
didn’t save me a lot of trouble - tried 2 find solution 4 my own but still, ended a really bugging problem…

i even tried clearInterval(my_interval) in a main swf, but didn’t find relevant adding emptyMovieclip name b4 it…

in the main swf:
clearInterval(empyMovieclip.my_interval);
worked fine.

dnx again :slight_smile:

…I actually registered here 2 thank u man :stuck_out_tongue:

No problem, you may also be interested in this post by MichaelxxOA

works well