PDA

View Full Version : How to "bubble" an event?


tata668
09-26-2007, 01:20 AM
I'm not sure "bubble" is the correct term, but here's what I'm trying to understand:

Let's say my Application main component contains a custom component A, that contains a custom component B, that contains a custom component C.

Application -> A -> B -> C

Now, let's say an event is dispatched by C.
If I want A to handle that event, do I really need to handle it by B, then having B to dispatch it, and finally having A to handle it? Is there a way to "bubble" the event to A without B handling it and dispatching it too?

I understand at one point you have to say "This is the A method that will be the handler", but I'm not sure how to achieve this when it's a deep component that dispatches the event first.

Is there some kind of pattern about this problem?


If the components were:

Application -> A -> B -> C -> D -> E -> F

What would be the best way to attach an handler on A for an event dispatched by F?


Thanks for any help!

drkstr
09-26-2007, 02:15 AM
I asked this question awhile back and never got a response. I think you just have to capture and dispatch the event up the chain until you get it where you want. However, this isn't necessary if you have a reference to the end target at the beginning of the chain.

Best Regards,
...aaron

tata668
09-26-2007, 04:32 PM
Thanks...

Let's hope someone will response one day!

tata668
10-11-2007, 10:57 PM
I found this and will probably use something similar:

http://www.actionscript.org/resources/articles/610/1/Centralized-Event-Management-in-Actionscript-20/Page1.html