EventDispatcher
Kind of class: | class |
---|---|
Inherits from: | CoreObject |
Implements: | |
Known subclasses: | |
Version: | 07/12/07 |
Author: | Aaron Clinger, Mike Creighton |
Classpath: | org.casalib.event.EventDispatcher |
File last modified: | Monday, 01 December 2008, 13:34:40 |
Provides event notification and listener management capabilities to objects.
Advantages of using this EventDispatcher:
Advantages of using this EventDispatcher:
- Ability to remap event handlers to a function not sharing the same name as the event.
- Ability to remove all event observers for a specified event.
- Ability to remove all event observers for a specified scope.
- Ability to remove all event observers subscribed to broadcasting object.
Summary
Constructor
Instance methods
- addEventObserver (scope:Object, eventName:String, eventHandler:String) : Boolean
- Registers a function to receive notification when a event handler is invoked.
- removeEventObserver (scope:Object, eventName:String, eventHandler:String) : Boolean
- Removes specific observer for event.
- removeEventObserversForEvent (eventName:String) : Boolean
- Removes all observers for a specified event.
- removeEventObserversForScope (scope:Object) : Boolean
- Removes all observers in a specified scope.
- removeAllEventObservers : Boolean
- Removes all observers regardless of scope or event.
- dispatchEvent (eventName:String) : Boolean
- Reports event to all subscribed objects.
- destroy : Void
- Removes any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.Instance methods inherited from CoreObject
- destroy : Void
Constructor
EventDispatcher
function EventDispatcher ()Instance methods
addEventObserver
function addEventObserver (scope:Object, eventName:String, eventHandler:String) : BooleanRegisters a function to receive notification when a event handler is invoked.#Parameters:scope :The target or object in which to subscribe.#eventName :Event name to subscribe to.#eventHandler:[optional] Name of function to recieve the event. If undefined class assumes#this.eventButton_mc.removeEventObserversForEvent("onRollOver");
matchesthis.eventButton_mc.removeEventObserversForScope(this);
.Returns:- Returns#
this.dispatchEvent("onRelease", 5, true, "Aaron");
if the observer was established successfully; otherwise {VISDOC_CODE_BLOCK_5}.
Example:-
this.eventButton_mc.addEventObserver(this, "onRollOver");
Specified by:destroy
function destroy () : VoidRemoves any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.#
Always callthis.eventButton_mc.addEventObserver(this, "onRollOver");
before deleting last object pointer.Overrides:Specified by:dispatchEvent
function dispatchEvent (eventName:String) : BooleanReports event to all subscribed objects.#Returns:- Returns#
this.eventButton_mc.addEventObserver(this, "onRollOver");
if observer(s) listening to specifed event were found; otherwisethis.eventButton_mc.removeEventObserver(this, "onRollOver");
.
Example:-
this.dispatchEvent("onRelease", 5, true, "Aaron");
Specified by:removeAllEventObservers
function removeAllEventObservers () : BooleanRemoves all observers regardless of scope or event.#Returns:- Returns {VISDOC_CODE_BLOCK_16} if observers were successfully removed; otherwise {VISDOC_CODE_BLOCK_17}.#
Specified by:removeEventObserver
function removeEventObserver (scope:Object, eventName:String, eventHandler:String) : BooleanRemoves specific observer for event.#Returns:- Returns {VISDOC_CODE_BLOCK_8} if the observer was successfully found and removed; otherwise {VISDOC_CODE_BLOCK_9}.#
Example:-
this.eventButton_mc.removeEventObserver(this, "onRollOver");
Specified by:removeEventObserversForEvent
function removeEventObserversForEvent (eventName:String) : BooleanRemoves all observers for a specified event.#removeEventObserversForScope
function removeEventObserversForScope (scope:Object) : BooleanRemoves all observers in a specified scope.# - dispatchEvent (eventName:String) : Boolean
- removeAllEventObservers : Boolean
- removeEventObserversForScope (scope:Object) : Boolean
- removeEventObserversForEvent (eventName:String) : Boolean
- removeEventObserver (scope:Object, eventName:String, eventHandler:String) : Boolean