I have some MovieClip
class
that has eventListener
, added from inside the constructor of the class
(it's MouseEvent.MOUSE_DOWN
). Now, I want to add the same listener externally, from parent class
, for other purposes. Will these two interfere with each other or it's okay?
It is absolutely legal to do this.
You need to have in mind how mouse events work. The event dispatching system inspects the display hierarchy of the object that triggers the mouse event. There is then a very root element - usually the stage - and the very bottom element, the event target.
Flash notifies now the entire hierachy about this event. If any of the elements in this hierarchy has a listener set to the mouse down event, it will get notified.
The notification is a 3 step procedure starting with the very root element going down (1) to the target element, notifying that element (2) and again bubbling up to the root element (3).
The top-down notification flow is called capture phase. To receive notification here you need to set the useCapture flag to true. The bottom-up notification flow is called bubblin phase. This is to what your parent is registered to by default if not set useCapture to true.
The target phase of an event follows the caputure phase. Here the actual event target that has triggered the event is notified.
Summary: Events are dispatched in a 3 phase procedure. Elements of a display hierarchy may listen to that event or not.
Found a web link here: http://www.adobe.com/devnet/actionscript/articles/event_handling_as3.html