This content has been marked as final. Show 8 replies
why don't you make the interval a "child" of dave. then when dave is removed all intervals that are children of dave will be removed.
kglad for the sake of my own curiosity what do you mean by "make a child of dave"?
Thanks for the reply and please bear with me as I am self taught, and not really sure what you mean.
however if i have a mc1, with mc2 nested in mc1 and Dave nested in mc2...ie.
and I remove mc1 from the stage,
that removes mc1, and its children (mc2 and dave), however for some reason it isn't clearing the setInterval within dave?
I say it isn't clearing because when you reacttach mc1, and therefore reset the Intervals within dave it is creating problems. I am sure the problems are arrising because it isn't clearing the intervals properly.
Is there a global clearInterval, that will clear any interval that is set? thanks J.
is that a global clearInterval? it appears to be doing something.
Is there any reason why you cant wrap these in a function and then just call the function when you need it?
i was wrong. you can make the interval reference a child of dave (mc1.mc2.dave.intervalNum=setInterval() ), but the interval itself is not a child and removing dave only removes the reference and fails to clear the interval.
however (for the op), the onUnload function will still execute as long as dave is unloaded, whether it's a child or not. your intervals will clear if they are correctly referenced.
Thanks Kglad. But when I removem.c. dave it is not always clearing the Intervals.
The only simple resolution I can see is if there is a way to globally clear any intervals that are running without an IntervalID.
For some reason the onUnoad function to clear the INtervals is not claring them and I can not bear to look at this any longer. Is there no way of simply globally clearing all running INtervals without a IntervalID? Anyone please..... aaaaaaaahhh!!
no, there's not clear all intervals function.
you can store all your intervals in an array (as they're created) and clear them all by cycling through the array elements.
or you can use the correct path to your intervals in your onUnload() function.