[CENTER]This class is a work in progress
[/CENTER]
Rather than adding event listeners directly to a target, you add the event listeners to the “DependentDispatcher” instance. (Note that the DependentDispatcher has a “click” event listener which is NOT triggered in the following case)
Then you can set the “target” property of the DependentDispatcher to set which object to listen to for events. Now, whenever events occur on the “target” (which in this case is the “click” event) the DependentDispatcher hears this, and all attached listener functions get executed.
The “target” can be changed to any other EventDispatcher (or even removed completely), and listeners added to the “DependentDispatcher” do not need to be removed or changed in any way. In fact, the listeners don’t even need to know what the “DependentDispatcher’s target” is, or if it even exists.
EXTRA NOTES
The “Event.currentTarget” property will always point to the current “DependentDispatcher.target”, NOT the DependentDispatcher instance!
The events will happen at the exact same time as the events would have if the event listeners had been added directly to the target. This class supports capture phase as well, but will trigger during the same capture phase as the target.
Currently, “Event.stopImmediatePropagation()” does not work. All listeners registered to the DependentDispatcher will continue running regardless. However, the remaining events on the target dispatcher will still stop from continuing. Same with canceling events.