tags:

views:

34

answers:

1

hi,

if I dispatch an event from a component, can this event be listened by the grandparent of the component ?

If not, what should I do to make it happen ?

Should I add a listener and dispatcher to the parent (component in the middle) as well ?

Thanks

A: 

What you are asking for are bubbling events. Have a look at the event propagation chapter in the Flex docs.

What you need is an event that bubbles so you'll need to set the bubble attribute to true, see the docs for the Event constructor. When you dispatch that event, it will be bubbling up the hierarchy in the third phase of the event propagation and you can listen for it all the way up.

ilikeorangutans
thanks, now the event dispatched by the children are received from the grandparent. I was wondering if the children can receive the event from the grandparent. (If the bubbling works in the opposite direction). I set bubbling to true, but apparently it doesn't work.
Patrick
In order to make it work I've added "stage" stage.addEventListener("UpdateBookmarksEvent", highlightMe);and now it works. Is this a good practice ? thanks
Patrick
Not sure if it is a good practice, because you bind the component, the child, to a certain structure. One approach could be to use a central class that is responsible for this particular piece of business logic. Or have a log at the Mate framework.
ilikeorangutans