Tutorial :Flash AS3 custom event should bubble up in “brother”MC



Question:

down vote

Hi,

this blogposts seem to be really old, but my question is fitting best in here. I am doing custom event dispatching on a MC construct like this

main_MC/room_MC/button_MC main_MC/room2_MC

I am dispatching a custom event from room_MC when receiving a button_MC.MOUSE.CLICK. It bubbles up to main_MC where I can do something with it. Really nice.

BUT: I want the dispatched event being handled in room2_MC. Is there a way to let it bubble up in room2_MC, too?

Thanks for your answers.

Regards.

Mike


thanks for your answer. The structure-examples you wrote are the same?

Ok. Bubbling goes in one direction only but I can definitely catch the Event in main_MC/room2_MC by adding stage.addEventListener to the constructor.

Ok. If I am somehow wrong with my solution I'll try your suggestion.

Again: Thanks for taking time to answer.

Mike


Solution:1

Currently I found out: Using stage.addEventListener in room2_MC seems to work.

But maybe there is a better solution?


Solution:2

It's a little unclear if this is one structure like this: main_MC/room_MC/button_MC main_MC/room2_MC or 2 like this: main_MC/room_MC/button_MC main_MC/room2_MC

Either way the answer is no, bubbling only goes in one direction, up to the objects parent.

You can however catch the event in main_MC and then call a method on room2_MC and pass the event object to it if you need to, for example if you're storing data in your custom events.

HTH


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »