0 Replies Latest reply on Oct 7, 2008 4:48 AM by SWiiT

    Add eventlistener to main Application in Module

    SWiiT Level 1
      Hi.
      I need to add a eventListener to the main application in a module without using parentApplication.
      I will unload the module that i have click the exit button.
      How can i do instead?

      Here is a bit of my code.

      ---------------- Application -------------------

      menuAppLoader = new ModuleLoader();
      menuAppLoader.url = "mySecondModule.swf";
      menuAppLoader.addEventListener("close", closeModule);

      private function closeModule(e:Event):void{
      systemLogger("Closing a window " + e.target.name);
      var tmpObject:ModuleLoader = e.target.parent as ModuleLoader;
      tmpObject.unloadModule();
      }


      ---------------- Module -------------------------

      parentApplication.addEventListener(MDIWindowEvent.CLOSE, closeHandler);

      private function closeHandler(e:Event):void {
      this.dispatchEvent(new Event("close",true,true));
      }