This content has been marked as final. Show 3 replies
Event bubbling doesn't require you to listen for an event at each level, but it does require that the component be able to receive the event.
For example, you can do: <mx:Application click="handleClick" ... /> and every click event from every component can be handled by the handleClick function. That's because Application has the click event metadata associated with it. If your CustomPanel does not have your custom event as its meta data, then you will get a compilation error because the compiler doesn't know that dateChanged is an event that CustomPanel can dispatch (even, if it if only passes through the component).
So yes, you need the [Event("dateChanged")] metadata on the component where you will add the event listener. In other words, if you have this:
You only need [Event("dateChanged")] on CustomPanel if you only have <CustomPanel dateChanged="...." /> because the event will bubble up through the other components as long as you dispatch the event with bubbles=true. CustomChild1 and CustomChild2 do not have to have the metadata.
But CustomComboBox has to have the metadata?
Not necessarily. Only if you want it to be referenced at compilation time. Something like:
<CustomComboBox dateChanged="handleEvent()" ... />
You can dispatch events which are not named by metadata.