简体   繁体   中英

Flash AS3 unload loaded SWF completely

how do i absolutely and completely unload a loaded SWF.

Here's the case. I have two different SWF, both have the same movieClips in the library with the same name and instance...but...both have different shape. So basically both are different but the names.

So i loaded the first.swf into the main.swf, in the first.swf contains button that order the loaded in the main.swf to unloadAndStop() and load the second.swf. But somehow the objects in the second.swf take the shape in the first.swf.

I hit the wall with this. How do i completely unload the first.swf

Thx guys

Try to load child swfs ( first.swf and second.swf ) into child application domains of the current application domain ( Usage C in this Article Working with application domains , you can also find code sample from this article below). With this technique you'll get:

  1. separate classes (all classes) of first.swf and second.swf from each other
  2. unload all the class definitions for garbage collection after unloading swf

AS3 from the article:

var appDomainC:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain); 

var contextC:LoaderContext = new LoaderContext(false, appDomainC); 
var loaderC:Loader = new Loader(); 
loaderC.load(new URLRequest("module3.swf"), contextC);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM