1 Reply Latest reply on Mar 10, 2010 2:12 PM by Flex harUI

    Question about Events

    andrewthorp Level 1

      My application looks like this:

       

      <mx:Application>

       

           <assets:NavBar /> <!-- This has buttons that fire off events when clicked -->

       

           <mx:ModuleLoader /> <!-- I need to catch the events here -->

       

      </mx:Application>

       

      When a button (for instance, PURCHASE), is clicked in the NavBar, the current module needs to perform some action. In order to achieve this, I was using "parentApplication.addEventListener" in the module initializers, and the navbar fires off events with bubble set to true. Whenever I load another module in, it adds another eventListener on the parent. If multiple modules are loaded in, it would fire off the eventHandler the same number of times (1 for each module that added a listener on the parent).

       

      What is a better way to do this? I don't think it is very smart to manually remove the eventListener on parent every time a module is unloaded, but I have no idea how else to have the module hear the event that is fired off from NavBar.

       

      Thanks!