So funny – this thread just caught my
eye because I just had to deal with the very same issue.
When you call dispatchEvent, the target
property is always overridden. Although I have seen a few erroneous examples,
the docs tell you not to set the target property in the event object because it
will be explicitly set to refer to the object that is dispatching the event.
Therefore, the original “target” will be lost.
I bubble up my events through chaining (for
example, a ThemeManager that propagates theme changes that propagates scheme
changes that propagates individual style (font and color) changes), but I
preserve the original event with a rootEvent property. The chain of handlers continue
to add this property to the new event that is getting dispatched up the chain,
preserving the value that each listener receives.
I should point out that athough preserving
the original event is useful, each listener in the chain generally needs to add
other context aside from just “bubbling” up the original event. The
ultimate listener can’t do much with the rootEvent object (eg, a font
style), without the additional context added by the listeners in the change (for
example, current theme : page title scheme : new font style).
-Tony
tony pujals| senior engineer | Yahoo! SiteBuilder
p. 408.349.6284 | e. [EMAIL PROTECTED] |
y!id tonypujals
From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Douglas Knudsen
Sent: Wednesday, November 23, 2005
10:37 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] event
bubbling Flex 1.5
helps to actually attach the file, eh? sorry about the
traffic...I
need some of that coffee now too Jesse.
DK
On 11/23/05, Douglas Knudsen
<[EMAIL PROTECTED]> wrote:
> lol!
>
> Ok, I attached a sample in a zip, hope it
stays attached. In it I
> have a A, B, C as an example of this thread
discussion. You can see
> that the final capture of the event in A
loses the original target.
> upon a suggestion elsewhere, I tried
'chaining' the events by catching
> the event in B and re-dispatching it.
This still messed with the
> target property of the event object.
Seems have to add this as a
> extra property in the original event.
>
> Jeff, looking at your evenmanger class now to
see if I can use this.
>
> DK
>
> On 11/23/05, JesterXL <[EMAIL PROTECTED]>
wrote:
> > ...er, sorry, C. 2nd cup of coffee
hasn't kicked in...
> >
> > ----- Original Message -----
> > From: "JesterXL"
<[EMAIL PROTECTED]>
> > To: <flexcoders@yahoogroups.com>
> > Sent: Wednesday, November 23, 2005 12:09
PM
> > Subject: Re: [flexcoders] event bubbling
Flex 1.5
> >
> >
> > I usually do:
> >
> > dispatchEvent({type:
"someEvent", target: this});
> >
> > Where this points to the component
dispatching the event. So, if A wants to
> > know who dispatched the event:
> >
> > function someEvent(o)
> > {
> > trace(o.target);
// this is A
> > }
> >
> > ----- Original Message -----
> > From: "Douglas Knudsen"
<[EMAIL PROTECTED]>
> > To: <flexcoders@yahoogroups.com>
> > Sent: Wednesday, November 23, 2005 11:52
AM
> > Subject: Re: [flexcoders] event bubbling
Flex 1.5
> >
> >
> > drat! I read your blog entry on
this too, forgot about it. Ok, in
> > my scenario below, I have A catching the
event dispatched in C. But
> > the target in the event still points to
B the middleman. I need A to
> > be able to be able to reference C in the
event. Is the only way to
> > add a reference to C in the event
dispatch in C?
> >
> > DK
> >
> > On 11/23/05, JesterXL
<[EMAIL PROTECTED]> wrote:
> > > It IS supported:
> > > http://www.jessewarden.com/archives/2005/11/event_bubbling.html
> > >
> > > ----- Original Message -----
> > > From: "Douglas Knudsen"
<[EMAIL PROTECTED]>
> > > To: <flexcoders@yahoogroups.com>
> > > Sent: Wednesday, November 23, 2005
11:29 AM
> > > Subject: [flexcoders] event
bubbling Flex 1.5
> > >
> > >
> > > not supportted I know, how to work
around?. Say I have 3 components
> > > A,B, and C. B is a child of A
and C is a child of B, each child among
> > > children possibly. Now,
if C fires an event called fooEvent, I can
> > > get A to catch it, but the
event.target points to B not C. The way I
> > > worked around this was in B I
caught the event then re-broadcast it so
> > > that A could catch it. In the
re-broadcast I added a reference to C
> > > in the event. How else can I
'bubble' up an event?
> > >
> > >
> > > --
> > > Douglas Knudsen
> > > http://www.cubicleman.com
> > > this is my signature, like it?
> > >
> > >
> > >
> > > --
> > > Flexcoders Mailing List
> > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Flexcoders Mailing List
> > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > --
> > Douglas Knudsen
> > http://www.cubicleman.com
> > this is my signature, like it?
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Douglas Knudsen
> http://www.cubicleman.com
> this is my signature, like it?
>
--
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS