Listening for events on the stage

Hey guys,

Sorry if this has been asked before. Can’t find it with the search.

Is it possible to listen for bubbled events on the stage?

Right now I have this working:

myClass.addEventListener(“customEvent”, eventHandler);


stage.addEventListener(“customEvent”, eventHandler);
addEventListener(“customEvent”, eventHandler);
Don’t work.

Essentially. I have a customEvent that multiple objects can dispatch, and I want the stage to be able to listen to all of them at once.

From within the class I’m calling:
dispatchEvent(new Event(“testEvent”, true));

I’d appreciate any help, thanks.

Ok I figured out what was wrong. I kept searching and found this:

By the looks of things events only bubble up if they’re on the display list.
My class was making the dispatch before it was on my display list. The problem is that some of my objects aren’t on the display list at all.

Right now my only solution is to listen to each of the objects manually, but that really complicates things and leads to GC headaches.

Anyone have any ideas?

Ok, hopefully this will be my last reply to my own message :smiley:

My current solution to the problem is to create a singletonClass

I pass the singleton a pointer to my eventHandler class.
Then I have all my subclasses call the Singleton which in turn calls the eventHandler.

Hehe, EASY!!! Now please excuse me as I swallow my tongue in a fit of insanity.

The static event dispatcher class on his site is nice also…