You coould try to use Application.application as medium for Events exchange,
within each module constructor/creationComplete handler say:
Application.application.addEventListener( MyEvent.MY_EVENT, onMyEvent );
then anywhere in the application say:
Application.application.dispatchEvent( new MyEvent( MyEvent.MY_EVENT ) )
Thanks for the quick response. But I need to register listener event in every module as I have to write an action related to each particular module.
Actually, I want to do some action for each module when the application resizes. So, for that to achieve the idea is to dispatch an event on the resize event of application and application does not need to take care of which module is currently loaded. It should be the responsibility of each module to handle its task on resize event.
Using Application.application can make the system tighly-coupled.
I see, that way you could go with OOP, extract BaseModule class out of your modules, and addEventListener once there.
Better solution is to maintain an internal list of loaded modules and enum them to notify each of them each time an Event occurs, for that
you could introduce ModuleDescriptor class which will carry the reference to the loaded module instance plus handy information
on what kind of module it is, etc.
Thanks a lot for your effort. ModuleLoader.child.dispatchEvent is working. I did a silly mistake . Yesterday I made some changes in the .actionScriptProperties file and accidentally removed two module names.
So, whatever changes I was making in the modules (adding event listeners) is not reflecting after compilation. So, silly mistake and I wasted my 5 hours on it today . Well, found it after cleaning my project. Thanks again for putting your efforts . I never went through the ModuleDescriptor class. Its really a learning for me.