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:
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
Instance methods inherited from Destroyable

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:

Instance methods

addEventListener

public function addEventListener (
type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false) : void

See also:
  • "IEventDispatcher documention for this method."

destroy

override public function destroy (
) : void

dispatchEvent

public function dispatchEvent (
event:Event) : Boolean

See also:
  • "IEventDispatcher documention for this method."

getTotalEventListeners

public function getTotalEventListeners (
type:String = null) : uint

Reports 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.
    #

hasEventListener

public function hasEventListener (
type:String) : Boolean

See also:
  • "IEventDispatcher documention for this method."

removeEventListener

public function removeEventListener (
type:String, listener:Function, useCapture:Boolean = false) : void

See also:
  • "IEventDispatcher documention for this method."

removeEventListeners

public function removeEventListeners (
) : void

Removes all event listeners.
#

removeEventsForListener

public function removeEventsForListener (
listener:Function) : void

Removes all events that report to the specified listener.
#
Parameters:
listener:
The listener function that processes the event.
#

removeEventsForType

public function removeEventsForType (
type:String) : void

Removes all events of a specific type.
#
Parameters:
type:
The type of event.
#

willTrigger

public function willTrigger (
type:String) : Boolean

See also:
  • "IEventDispatcher documention for this method."