Reputation: 49
I'm loading some swf files at 0 on my stage. They are the pages of my site.
To change from page to page I use removeChildAt(0) and then I addChildAt("page_title", 0).
The problem is that removeChild dont delete the functions from the first swf file loaded (before unloaded).
How can I stop then?
Do I have to use other way to removeChild?
Thanx!
Upvotes: 1
Views: 1610
Reputation: 2135
It sounds to me like you aren't actually removing them. First things first, removing something from the display list is only a visual/interactive change. It is still running until you remove any references to it, being event listeners or w/e, and then you must set it to null so that garbage collection will grab it on the next cycle.
If you are using Flash Player 10, spender is correct that unloadAndStop will work for you as they just recently created it to fix your very problem.
I just thought I should explain what is going on, because people should not only know about the fix, but why things happen.
One other suggestion, I wouldn't load these movies to stage, I would create a container Sprite
/MovieClip
to hold them, that way even if you add other things later, they are separated, clean, and easy to access through their parent (imageContainer_mc
for instance).
Upvotes: 1
Reputation: 171
Alternatively, you can load the submovie into a different ApplicationDomain to insulate the loaded code from your main app. Take a look at the flash.system.ApplicationDomain
class (it's a parameter to the Loader.load()
method).
Upvotes: 0
Reputation: 120380
Assuming you are loading with a Loader you can use the unloadAndStop method.
More info here:
http://www.gskinner.com/blog/archives/2008/07/additional_info.html
Upvotes: 1