2 Replies Latest reply on Jul 20, 2011 10:05 AM by Flex harUI

    Module Manger

    _spoboyle Level 4

      I am trying to load a module using ModuleManager (the module is a spark module)

       

      var moduleInfo:IModuleInfo = ModuleManager.getModule("module.swf");
      moduleInfo.addEventListener(ModuleEvent.READY, moduleLoaded);
      moduleInfo.addEventListener(ModuleEvent.ERROR, error);
      moduleInfo.addEventListener(ModuleEvent.PROGRESS, progress);
      moduleInfo.addEventListener(ModuleEvent.SETUP, setup);
      moduleInfo.addEventListener(ModuleEvent.UNLOAD, unload);
      moduleInfo.load(null, null, null, moduleFactory);
      

       

      private function error(event:ModuleEvent):void
      {
           trace("error: " + event);
      }
      
      private function moduleLoaded(event:ModuleEvent):void
      {
           trace("module loaded");
      }
      

       

      I do not recieve any events

        • 1. Re: Module Manger
          _spoboyle Level 4

          I found the problem for some reason moduleInfo cannot be declared as a local variable. If you do it seems that it gets destroyed and therefore no events.

           

          really quite annoying since i don't need a member variable for this

           

          private var moduleInfo:IModuleInfo;
          

           

          private function init():void
          {     
               moduleInfo = ModuleManager.getModule("modules/ContactModule.swf");
               moduleInfo.addEventListener(ModuleEvent.READY, moduleLoaded);
               moduleInfo.addEventListener(ModuleEvent.ERROR, error);
               moduleInfo.addEventListener(ModuleEvent.PROGRESS, progress);
               moduleInfo.addEventListener(ModuleEvent.SETUP, setup);
               moduleInfo.addEventListener(ModuleEvent.UNLOAD, unload);
               moduleInfo.load();
          }
          

           

          private function moduleLoaded(event:ModuleEvent):void
          {
               trace("module loaded");
          }
          
          • 2. Re: Module Manger
            Flex harUI Adobe Employee

            That's been discussed before.  You need a strong reference to the

            module/moduleinfo otherwise it will get garbage-collected