actionscript 3 - Flex ModuleManager unload module -


i use modulemanager load module, class:

 public class loadmodule     {         private static var info:imoduleinfo;         private static var display:ivisualelement;         private static var downloadbar:progressbar;         private static var parent:group;           public function loadmodule()         {          }         //load module         public static function load(url:string, parent:group, bar:boolean = true):void {             loadmodule.parent = parent;             info = modulemanager.getmodule(url);             info.addeventlistener(moduleevent.ready, readyhandler);             info.addeventlistener(moduleevent.setup, setuphandler);             info.addeventlistener(moduleevent.error, errorhandler);             info.load(null, null, null, parent.modulefactory);          }          //add display object         private static function readyhandler(event:moduleevent):void {             loadmodule.display = event.currenttarget.factory.create() ivisualelement;             parent.addelement(loadmodule.display);         }          private static function setuphandler(event:moduleevent):void {          }         //unload module         public static function unload():void {             if (loadmodule.info != null) {                 loadmodule.info.addeventlistener(moduleevent.unload, unloadhandler);                 loadmodule.info.unload();                 if (parent.getelementindex(loadmodule.display) != -1) {                     parent.removeallelements();                     loadmodule.display = null;                 }             }         }          private static function unloadhandler(event:moduleevent):void {             loadmodule.info.removeeventlistener(moduleevent.unload,unloadhandler);             trace("unloadmodue");         }         //         private static function progresshandler(event:moduleevent):void {             downloadbar.label = "haved" + math.round((event.bytesloaded /event.bytestotal) * 100) + "%";         }          private static function errorhandler(event:moduleevent):void {             throw error(event.errortext);         }          public static function setdownloadbar(downloadbar:progressbar):void {             loadmodule.downloadbar = downloadbar;         }     } 

then load module , unload module:

 loadmodule.unload(); // 1    lodmodule.load('..one.swf', parent);    loadmodule.unload(); //2    lodmodule.load('...one.swf', parent); 

in theory, it's 1 module in application, , use "popupmanager" pop box, shoud 1 box. but, in fact, it's pop tow box. use flash builder debug code, , not notice me unloade swf.. guess, has tow module in appliction. so, need help. how unload module in modulemanager. wish 1 module in application , not tow. thanks.

if understand question correctly, sounds having trouble unloading module. there's great adobe resource can solve these issues. few considerations:

"if have module not unload, steps diagnose problem are: 1) make sure module being loaded child applicationdomain (use default parameters load() method in cases) 2) use profiler make sure there no references objects in module."

if reference objects in module, module not unload. want check following areas make no reference module in question:

  1. styles
  2. resources
  3. externalinterface.addcallback functions
  4. timers , timer mechanisms
  5. listeners
  6. focus
  7. remote objects
  8. loaded images

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -