What he said - events only bubble up the display list.
EventDispatcher doesn't extend DisplayObject (rather the other way
round) - so even if your Sprite is an instance inside an EventDispatcher
it can't be on the EventDispatcher's stage (EventDispatcher doesn't have
a stage).

Instead of subclassing EventDispatcher, consider subclassing a
DisplayObject (Sprite or MovieClip) - which because they extend
EventDispatcher will give you access to all the functionality you need.

Barry.


-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Steve
Mathews
Sent: Thursday, 18 March 2010 2:08 p.m.
To: Flash Coders List
Subject: Re: [Flashcoders] bubbling listening

Might be obvious, but bubbling only works on the display list. So if
your
classes aren't all on the display list, then it won't work.

Steve

On Wed, Mar 17, 2010 at 11:39 AM, Mendelsohn, Michael <
michael.mendels...@fmglobal.com> wrote:

> Hi Jason, thanks for responding!
>
> > Make sense?
> Almost.  :-)
>
> > What do you mean "The EventDispatcher contains an instance of a
sprite."
>
> The EventDispatcher has a private var that's a reference to a custom
class
> that extends Sprite.
> The Event Dispatcher is instanced in the singleton, it's not on the
stage,
> it just directs traffic, so to speak.
>
> > Normally what you would do is not create an instance of
EventDispatcher,
> but instead have your custom class extend Sprite (which already
extends
> EventDispatcher anyway), have that sprite dispatch a custom event.
>
> Yes, that's happening.
>
> > Then have your class listen to the instance of that class for the
custom
> event you dispatch.
>
> Yes, I'm doing that too.
>
> > So in summary, you write an event class, dispatch
> that custom event from the "sprite" class (the custom class that
extends
> sprite) and listen for that event on that instance in your Singleton
> (the fact that it's a Singleton should be irrelevant).
>
> This is the part I'm not getting to work. What I have working is the
> following:
>
> Singleton
>        - has private var EventDispatcher
>
> EventDispatcher
>        - has private var CustomSprite
>
> CustomSprite dispatches CustomEvent.
>
> EventDispatcher catches CustomEvent from Sprite.
> EventDispatcher dispatches same CustomEvent.  <-- unnecessary step??
> Singleton catches CustomEvent from EventDispatcher (passed along from
> CustomSprite).
>
> What I want is:
> CustomSprite dispatches CustomEvent
> Singleton catches CustomEvent.
>
> Within singleton, this does *not* work:
> myEventDispatcher[myCustomSprite].addEventListener...
>
> I have to "pass" the event up the ladder to the singleton.  I'd rather
leap
> over the EventDispatcher.
>
> - Michael M.
>
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to