Quote:
|
Originally Posted by torrential
i don't know why it doesn't just work with eventdispatcher
|
The way it really works is that you can only add event listeners to objects that dispatch those same events. The EventDispatcher class isn't programmed to dispatch ENTER_FRAME events. But somewhere in the DisplayObject class definition (that we don't get to see, except in the documentation), the DisplayObject class is actively dispatching ENTER_FRAME events. And therefore, so is any class that inherits from DisplayObject, for example: Sprite.
(The one exception to the above rule about only being able to add event listeners to the same objects that dispatch them has to do with events that "bubble" up the display list, in which case you can add an event listener to a display object container for an event that is dispatched by one of its children).
Of course, you can add any event listener you want to any object that extends EventDispatcher (and therefore has an addEventListener method), and you won't get any errors. It will just fail silently if the object doesn't also dispatch that event (as programmed by its class).