8 Replies Latest reply on Jul 10, 2009 12:37 PM by Darrell Loverin

    How to unload dynamically loaded modules?

    TodLoch Level 1

      Hi,

      I have a problem with unloading module, which I loads dynamically.

      Here is a fragment my code:

       

      <TitledWindow .......creationComplete="init()"/>

      ......

      <mx:Accordion id="lista_ryzyk">

      </mx:Accordion>

      .....

       

      <mx:Script>

      ...

      public function init():void

      {

          CairngormEventDispatcher.getInstance().addEventListener(LoadRisksEvent.EVENT_RESULT, populateAccordion);

      ......

      }

       

       

      public function populateAccordion(event:CairngormEvent):void

      {

      ...

           lista_ryzyk.removeAllChildern();

           for (i in risks)

           {

                var m:ModuleLoader = new ModuleLoader();

                m.url = path_to_module;

                m.label = module_label;

                m.loadModule();

           }

           lista_ryzyk.addChildAt(m,Number(i));

      ....

      }

      ....

      </mx:Script>

       

      The modules loads fine. Each module adds own eventListener for some event. It works fine, but ONLY for first time. For next invoke populateAccordion function, the modules loads, but don't reacts for event. I investigate !!! that for events reacts that modules, which was loaded for the first time!!! How to remove it????