views:

281

answers:

2

Is there a way how modules can listen to parent application event? My current solution that works is:

private function directoryRemoteObject_saveCompany_resultHandler(e:ResultEvent):void
{
  this.directoryModuleLoader.child.dispatchEvent(new CompanyEvent(CompanyEvent.COMPANY_SAVED, e.result as int));
}

this means that I need to dispatch event for every module. Isn't there better solution? Thanks.

A: 

How about just adding a listener?

        parentApplication.addEventListener( ...)
I want modules to listen for events, not parentApplication.
Viliam Husár
This would be called from a module, hence you would be listenning from the module to events dispatched by the parent application.Sounds close?
i'm sorry, now i understand. thanks.
Viliam Husár
You need to trigger the event within the application and place the addListener() in the module.The example from Nirmal will hopefully shed some light.
A: 

Use below code to dispatch event from application context

Application.application.dispatchEvent(new Event("Test"));

Use below code to listen event from module

Application.application.addEventListener("Test",function1);

Nirmal Singh