I'm developing an AIR application with Flash Builder 4 Beta 2 (nightly SDK) an am not using a framework like mate. I have a couple of views and components in my application. An outline might look like this:
root
|- mainview
|-- toolbar
|-- catalogue view
|--- tree
|--- datagrid
|-- statusbar
This is not 100% the structure of my project, but may suffice as an example. When the app get's initialized, the tree loads it's data which in my case is a list of categories. When the users clicks on an item in the tree, the data for the datagrid loads.
On every click on a tree item I dispatch an event. This event bubbles and carries the VO of the clicked item. Now I want my datagrid to catch this event. Currenty I register the event listener for this event like this (using a class and function):
FlexGlobals.topLevelApplication.addEventListener(eventName, this.eventHandler);
This code is executed in the datagrid's creation complete Listener. Somehow, this seems a bit buggy to mee (altough it works). Or is it a common technic to register a component's event listener at the top level application?