Argh!  It worked!

So all I had to do actually was set useCapture in the 
systemManager.addEventListener to true, and it worked right away.  Is 
bubbling then set to true by default?

Also, should I be in the habit of removing the listener when popups 
are removed?  I've been noticing that in other code I've looked at 
online.

Thanks Alex!  Makes a whole lot more sense now!
 - Chris



--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> The top of the display list is the stage.  The stage always has one
> child (the root) which in Flex apps is a SystemManager.  The app 
and all
> popups are children of the systemManager.
> 
>  
> 
> Stage -> SystemManager ->      Application
> 
>                                                 PopUp1
> 
>                                                 PopUp2
> 
>  
> 
> The event model in Flash/Flex is based on the DOM event model
> http://www.w3.org/TR/DOM-Level-3-Events/events.html
> 
> If you search for bubbling and capture in our docs you'll find 
easier to
> read descriptions.
> 
>  
> 
> But basically, when PopUp2 dispatches an non-bubbling event, the 
stage
> first dispatches the event in capture phase, then the SystemManager 
in
> capture phase, then PopUp2 as a regular event.
> 
> If the event was a bubbling event, the same would happen, but then
> SystemManager would dispatch it again in bubbling phase and finally 
the
> Stage in bubbling phase.
> 
>  
> 
> addEventListener has a parameter as to whether you want to listen in
> capture phase or not.  Events have a constructor parameter as to 
whether
> the event bubbles or not.  Capture phase basically allows 
containers to
> supervise and block events going to their children.  Bubble phase 
serves
> as notification that the child dispatched an event.
> 
>  
> 
> In theory this makes the Popups even more loosely coupled from each
> other than the other suggestions.  Each Popup simply dispatches 
events.
> Other code can capture all events coming from popups (yes, it has to
> know what the event name is).  Popups can listen to other popups 
without
> having to watch for their creation and destruction since you are 
going
> to addEventListener on systemManager instead of the actual popups.
> 
>  
> 
> ________________________________
> 
> From: [email protected] 
[mailto:[EMAIL PROTECTED] On
> Behalf Of qnotemedia
> Sent: Wednesday, March 21, 2007 4:44 AM
> To: [email protected]
> Subject: [flexcoders] Re: Event Dispatching through more than one
> component
> 
>  
> 
> OK, I understood the other responses, but not this one. Agreed that 
I 
> tried setting bubbles to true in my customEvent, and then each 
event 
> instance, and the dispatched event did not pass through embedded 
> windows. But I've never used systemManager, nor do I entirely 
> understand bubbling. Can you forward me to an example or doc 
> explaining this?
> 
> And does this somewhat move away from loosely-coupled components 
(which 
> I'm trying real hard to achieve!).
> 
> Thanks,
> - Chris
> 
> --- In [email protected] <mailto:flexcoders%
40yahoogroups.com>
> , "Alex Harui" <aharui@> wrote:
> >
> > Each popup is parented by the systemManager so it won't bubble 
from 
> > one popup to the next. However, each popup can listen to the 
> > systemManager for the event to bubble to it, or listen in capture
> > phase so you don't have to use bubbling.
>


Reply via email to