views:

607

answers:

3

Hi there!,

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!

A: 

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%5Finfo.html

spender
He would also have to have published for flash player 10.
Brian Hodge
+1  A: 

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).

Brian Hodge hodgedev.com

Brian Hodge
A: 

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).

IanT