StageEventProxy
| Kind of class: | public class |
|---|---|
| Package: | org.casalib.events |
| Inherits from: | Destroyable |
| Implements: | |
| Version: | 02/11/10 |
| Author: | Aaron Clinger |
| Classpath: | org.casalib.events.StageEventProxy |
| File last modified: | Sunday, 28 March 2010, 11:55:55 |
Created an event proxy between the Stage that implements IRemovableEventDispatcher and IDestroyable.
Usage note:
- You must first initialize StageReference before using this class.
Example:
-
package { import flash.events.KeyboardEvent; import org.casalib.display.CasaMovieClip; import org.casalib.events.StageEventProxy; import org.casalib.util.StageReference; public class MyExample extends CasaMovieClip { protected var _stageEventProxy:StageEventProxy; public function MyExample() { super(); StageReference.setStage(this.stage); this._stageEventProxy = new StageEventProxy(); this._stageEventProxy.addEventListener(KeyboardEvent.KEY_DOWN, this._onKeyDown); this._stageEventProxy.addEventListener(KeyboardEvent.KEY_UP, this._onKeyUp); } protected function _onKeyDown(e:KeyboardEvent):void { trace("Key down " + e.keyCode); if (e.keyCode == 65) { trace("a key pressed!"); this._stageEventProxy.removeEventListeners(); } } protected function _onKeyUp(e:KeyboardEvent):void { trace("Key up " + e.keyCode); } } }
Summary
Constructor
- StageEventProxy (stageId:String = StageReference)
- Created a new StageEventProxy.
Instance properties
Instance properties inherited from Destroyable
Instance methods
- dispatchEvent (event:Event) : Boolean
- addEventListener (type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false) : void
- removeEventListener (type:String, listener:Function, useCapture:Boolean = false) : void
- hasEventListener (type:String) : Boolean
- willTrigger (type:String) : Boolean
- removeEventsForType (type:String) : void
- Removes all events of a specific type.
- removeEventsForListener (listener:Function) : void
- Removes all events that report to the specified listener.
- removeEventListeners : void
- Removes all event listeners.
- getTotalEventListeners (type:String = null) : uint
- Reports the number of listeners for a specific event or the total listeners for all events.
- destroy : void
Instance methods inherited from Destroyable
- getTotalEventListeners (type:String = null) : uint
Constructor
StageEventProxy
public function StageEventProxy (stageId:String = StageReference)Created a new StageEventProxy.Parameters:stageId:An identifier that corresponds to a stored Stage in StageReference.Usage note:- You must first initialize StageReference before using this class.
Instance methods
addEventListener
public function addEventListener (type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false) : voidSee also:- "IEventDispatcher documention for this method."
dispatchEvent
public function dispatchEvent (event:Event) : BooleanSee also:- "IEventDispatcher documention for this method."
getTotalEventListeners
public function getTotalEventListeners (type:String = null) : uintReports the number of listeners for a specific event or the total listeners for all events.#Parameters:type:The name of event or#package { import flash.events.KeyboardEvent; import org.casalib.display.CasaMovieClip; import org.casalib.events.StageEventProxy; import org.casalib.util.StageReference; public class MyExample extends CasaMovieClip { protected var _stageEventProxy:StageEventProxy; public function MyExample() { super(); StageReference.setStage(this.stage); this._stageEventProxy = new StageEventProxy(); this._stageEventProxy.addEventListener(KeyboardEvent.KEY_DOWN, this._onKeyDown); this._stageEventProxy.addEventListener(KeyboardEvent.KEY_UP, this._onKeyUp); } protected function _onKeyDown(e:KeyboardEvent):void { trace("Key down " + e.keyCode); if (e.keyCode == 65) { trace("a key pressed!"); this._stageEventProxy.removeEventListeners(); } } protected function _onKeyUp(e:KeyboardEvent):void { trace("Key up " + e.keyCode); } } }for all events.Returns:- The number of listeners.#
Specified by:hasEventListener
public function hasEventListener (type:String) : BooleanSee also:- "IEventDispatcher documention for this method."
removeEventListener
public function removeEventListener (type:String, listener:Function, useCapture:Boolean = false) : voidSee also:- "IEventDispatcher documention for this method."
removeEventListeners
public function removeEventListeners () : voidRemoves all event listeners.#Specified by:removeEventsForListener
public function removeEventsForListener (listener:Function) : voidRemoves all events that report to the specified listener.#Parameters:listener:The listener function that processes the event.#Specified by:removeEventsForType
public function removeEventsForType (type:String) : voidRemoves all events of a specific type.#Parameters:type:The type of event.#Specified by:willTrigger
public function willTrigger (type:String) : BooleanSee also:- "IEventDispatcher documention for this method."
- removeEventListeners : void
- removeEventsForListener (listener:Function) : void