Reputation: 59
say an application has panel and panel has button and textField or textArea. we click on a button to hit a service say via cairngorm framework.
The Events lifecycle follows the capture-target-bubble cycle in the display hierarchy like the MouseClick event on button will call the handlers for the listeners attached to button and/or panel and/or application and/or stage since the flow moves in this direction.
How do the event on non hierarchy works e.g the result from the service fires a custom event DataRecieved. we have a listener attached to the panel/button for this dataRecieved event. How do this listener gets the information? how the event lifecycle comes into this picture?
Can anyone explain this?
Thanks!
Upvotes: 0
Views: 269
Reputation: 59
I found out the concept of GlobalEventDispatcher to which we can attach listeners and dispatch from the same.
a ref from another question was helpful - Flex Custom Event dispatching The important point is that - the instance of dispatcher must be same. we can keep a Custom Global singleton event dispatcher for our application or we can use stage/systemManager/FexGlobals.toplevelapplicaton for the purpose which might not be a good Practice.
Upvotes: 0
Reputation: 1000
If you dispatch a custom event on a Flex UIComponent via dispatchEvent
, the UIComponent takes care of bubbling the event through the display hierarchy, as long as the bubbles
flag in the Event object is true.
Upvotes: 0
Reputation: 76750
Since it's a non-DisplayObject, the Event only has a target phase. That means that only listeners attached to the Object which is identical to the Object in the target
property of the Event work. Hence, non-DisplayObject's can only dispatch Events to themselves. At least that's how I understand it.
In answer to a related question there is some discussion of writing custom EventDispatcher's that would enable a bubbling for non-DisplayObject's.
Upvotes: 1