RE: [flexcoders] Re: Event Dispatching through more than one component

2007-03-23 Thread Gordon Smith
 Is bubbling then set to true by default?

As Alex said, Events have a constructor parameter as to whether the
event bubbles or not. In other words it is up to the code that creates
the event to decide whether it bubbles or not. For each event dispatched
by the Player or Flex Framework classes, the Adobe(r) Flex(tm) 2
Language Reference documents whether it bubbles or not. For example,
look at the doc for the (inherited) 'click' event of Button. It has
 
The event has thefollowing properties:
 
Properties Values
--- --
bubbles true
...
 
- Gordon



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of qnotemedia
Sent: Friday, March 23, 2007 5:59 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Event Dispatching through more than one
component



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 flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, 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
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: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com

[mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
] On
 Behalf Of qnotemedia
 Sent: Wednesday, March 21, 2007 4:44 AM
 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
 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 flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com  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.




 


RE: [flexcoders] Re: Event Dispatching through more than one component

2007-03-23 Thread Alex Harui
Yes, if you don't remove listeners on systemManager you will probably
leak memory.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Gordon Smith
Sent: Friday, March 23, 2007 9:51 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: Event Dispatching through more than one
component

 

 Is bubbling then set to true by default?

As Alex said, Events have a constructor parameter as to whether the
event bubbles or not. In other words it is up to the code that creates
the event to decide whether it bubbles or not. For each event dispatched
by the Player or Flex Framework classes, the Adobe(r) Flex(tm) 2
Language Reference documents whether it bubbles or not. For example,
look at the doc for the (inherited) 'click' event of Button. It has

 

The event has thefollowing properties:

 

Properties Values

--- --

bubbles true

...

 

- Gordon

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of qnotemedia
Sent: Friday, March 23, 2007 5:59 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Event Dispatching through more than one
component

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 flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, 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
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: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com

[mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
] On
 Behalf Of qnotemedia
 Sent: Wednesday, March 21, 2007 4:44 AM
 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
 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 flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com  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.


 



RE: [flexcoders] Re: Event Dispatching through more than one component

2007-03-21 Thread Alex Harui
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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of qnotemedia
Sent: Wednesday, March 21, 2007 4:44 AM
To: flexcoders@yahoogroups.com
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 flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] 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.

 



RE: [flexcoders] Re: Event Dispatching through more than one component

2007-03-20 Thread Alex Harui
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.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Paul DeCoursey
Sent: Tuesday, March 20, 2007 1:52 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Event Dispatching through more than one
component

 

Have you tried setting bubbles to true on your event? You should be
able to bubble the event and it will get up to the systemManager where
it can be handled by your app.

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Jon Hirschi [EMAIL PROTECTED] wrote:

 It doesn't happen automatically. You need to set this up, but it's
not hard to do. the thing about popups is that they act essentially
like their own application. so they don't normally pass events
outside of the popup window. events originate and terminate with the
popup. 
 
 so for example, if you have 
 
 parent application
 |
 popup #1
 |
 popup #2
 
 dispatch the event in popup #2 and listen for it in popup #1.
 
 in popup #2 you would do a dispatchEvent(new
Event(myCustomEventPopUp2))
 and in popup #1 in the same location that you generate/ create
popup#2 you would put an event listener on popup #2.
 ie: 
popupObj.addEventListener(myCustomEventPopUp2,myPopUp2Function)
 
 then in your function:
 
 function myPopUp2Function(event) {
 dispatchEvent(event)
 }
 Then in your parent app, you would put in the same kind of listener
as you had in the first popup:
 ie: 
popupObj.addEventListener(myCustomEventPopUp2,myPopUp2Function)
 
 It's a little round about, but it will get the job done. 
unfortunately, flex doesn't handle this sort of event handling.
 
 Hope that helps.
 
 Jon Hirschi
 
 
 - Original Message 
 From: qnotemedia [EMAIL PROTECTED]
 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
 Sent: Tuesday, March 20, 2007 1:21:29 PM
 Subject: [flexcoders] Event Dispatching through more than one
component
 
 I'm still messing around with custom events.
 
 If I have a popup embedded within another popup and want to dispatch
an 
 event from the top-most component down to the parent application, do I

 have to dispatch it to the first popup, and then redispatch the same 
 event to the parent app?
 
 Is there any way to dispatch an event, but have it automatically go 
 through all components down to the root? Obviously I've tried, but 
 events seems to stop at the parent component, and they are not 
 automatically delivered to their parent's parent, etc.
 
 What I'm thinking of doing instead is having each popup send a message

 to the root to open other embedded popups, so that they are ALL
created 
 from the root application rather than the popup. In essence, a custom 
 popup manager.
 
 But I'm still curious if there's a way around the above scenario.
 
 Thanks,
 - Chris
 
 
 
 
 
 

__
 Don't pick lemons.
 See all the new 2007 cars at Yahoo! Autos.
 http://autos.yahoo.com/new_cars.html
http://autos.yahoo.com/new_cars.html