flash actionscript:
Okay I have a m.c. with an instance name of 'dave'. Dave m.c. has a setInterval that I want to clear when the m.c. is removed. this.onUnload=function():Void{ clearInterval(fadeOutInterval); clearInterval(zoomInterval);} The above code works fine if dave m.c is removed. However I also want it to work if dave m.c. is within another m.c. and the outer m.c. is removed. eg. outerMc.outerMc.dave but if you remove outerMc instead of dave the onUnload is not clearing the setINterval. Any ideas? thanks J.
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. mc1.mc2.dave 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 there any reason why you cant wrap these in a function and then just call the function when you need it? function globalClear() { clearInterval(fadeOutInterval); clearInterval(zoomInterval); }
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.
Don't see what you're looking for? Try a search.
|