[as3] Event Propagation Issue on Stage

  • Lets say I have two sprites on the stage added with:

    DisplayObjectContainer( root ).addChild( sprite1 );
    DisplayObjectContainer( root ).addChild( sprite2 );

    If I dispatch an event within sprite1, sprite2 doesn't receive it. Am I missing something obvious here? I've read all I can find on AS3 event propagation (including senocalars excelent posts) but cant find a solution.

    I understand that events always start at the stage and propagate down to the originator and then back up, but I need it to go back down to the other sprite.

    Making sprite2 a child of sprite1 obviously solves the problem by creates a tight coupling.

    Ideas?


  • if you want it to go back down, you can clone the event, and dispatch it from your root.

    The problem here is that your event stops when it hits the surface (the end of the bubble). Thus you have to re propogate the event back down again (the capture phase) So make sure your events are set up to capture the right phases.

    But ... I have never had to perform such trickery. Maybe if you rethought about your design, you might find you don't have to do it at all.


  • The simple answer is that it just doesn't work that way. Your other sprite will not recieve those events through propagation. That doesn't mean that sprite cant listen for events coming from the other one

    sprite1.addEventListener("click", sprite2.method);

    sprite2 just won't recieve those events as its own.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about [as3] Event Propagation Issue on Stage , Please add it free.