Packageorg.osflash.signals.natives
Classpublic class NativeSignal
InheritanceNativeSignal Inheritance Object
Implements INativeDispatcher

The NativeSignal class provides a strongly-typed facade for an IEventDispatcher. A NativeSignal is essentially a mini-dispatcher locked to a specific event type and class. It can become part of an interface.

Default MXML PropertyeventClass



Public Properties
 PropertyDefined By
  eventClass : Class
The class of event permitted to be dispatched.
NativeSignal
  eventType : String
The type of event permitted to be dispatched.
NativeSignal
  numListeners : uint
[read-only] The current number of listeners for the signal.
NativeSignal
  target : IEventDispatcher
The object considered the source of the dispatched events.
NativeSignal
  valueClasses : Array
An optional array of classes defining the types of parameters sent to listeners.
NativeSignal
Protected Properties
 PropertyDefined By
  _eventClass : Class
NativeSignal
  _eventType : String
NativeSignal
  slots : SlotList
NativeSignal
  _target : IEventDispatcher
NativeSignal
  _valueClasses : Array
NativeSignal
Public Methods
 MethodDefined By
  
NativeSignal(target:IEventDispatcher = null, eventType:String, eventClass:Class = null)
Creates a NativeSignal instance to dispatch events on behalf of a target object.
NativeSignal
  
add(listener:Function):ISlot
Subscribes a listener for the signal.
NativeSignal
  
addOnce(listener:Function):ISlot
Subscribes a one-time listener for this signal.
NativeSignal
  
addOnceWithPriority(listener:Function, priority:int = 0):ISlot
Subscribes a one-time listener for this signal.
NativeSignal
  
addWithPriority(listener:Function, priority:int = 0):ISlot
Subscribes a listener for the signal.
NativeSignal
  
dispatch(... valueObjects):void
Dispatches an object to listeners.
NativeSignal
  
dispatchEvent(event:Event):Boolean
Unlike other signals, NativeSignal does not dispatch null because it causes an exception in EventDispatcher.
NativeSignal
  
remove(listener:Function):ISlot
Unsubscribes a listener from the signal.
NativeSignal
  
removeAll():void
Unsubscribes all listeners from the signal.
NativeSignal
Protected Methods
 MethodDefined By
  
registerListenerWithPriority(listener:Function, once:Boolean = false, priority:int = 0):ISlot
NativeSignal
  
registrationPossible(listener:Function, once:Boolean):Boolean
NativeSignal
Property Detail
_eventClassproperty
protected var _eventClass:Class

_eventTypeproperty 
protected var _eventType:String

_targetproperty 
protected var _target:IEventDispatcher

_valueClassesproperty 
protected var _valueClasses:Array

eventClassproperty 
eventClass:Class

The class of event permitted to be dispatched. Will be flash.events.Event or a subclass.


Implementation
    public function get eventClass():Class
    public function set eventClass(value:Class):void
eventTypeproperty 
eventType:String

The type of event permitted to be dispatched. Corresponds to flash.events.Event.type.


Implementation
    public function get eventType():String
    public function set eventType(value:String):void
numListenersproperty 
numListeners:uint  [read-only]

The current number of listeners for the signal.


Implementation
    public function get numListeners():uint
slotsproperty 
protected var slots:SlotList

targetproperty 
target:IEventDispatcher

The object considered the source of the dispatched events.


Implementation
    public function get target():IEventDispatcher
    public function set target(value:IEventDispatcher):void
valueClassesproperty 
valueClasses:Array

An optional array of classes defining the types of parameters sent to listeners.


Implementation
    public function get valueClasses():Array
    public function set valueClasses(value:Array):void
Constructor Detail
NativeSignal()Constructor
public function NativeSignal(target:IEventDispatcher = null, eventType:String, eventClass:Class = null)

Creates a NativeSignal instance to dispatch events on behalf of a target object.

Parameters
target:IEventDispatcher (default = null) — The object on whose behalf the signal is dispatching events.
 
eventType:String — The type of Event permitted to be dispatched from this signal. Corresponds to Event.type.
 
eventClass:Class (default = null) — An optional class reference that enables an event type check in dispatch(). Defaults to flash.events.Event if omitted.
Method Detail
add()method
public function add(listener:Function):ISlot

Subscribes a listener for the signal.

Parameters

listener:Function — A function with arguments that matches the value classes dispatched by the signal. If value classes are not specified (e.g. via Signal constructor), dispatch() can be called without arguments.

Returns
ISlot — a ISlot, which contains the Function passed as the parameter

Throws
flash.errors:IllegalOperationError IllegalOperationError: You cannot addOnce() then add() the same listener without removing the relationship first.
 
ArgumentError ArgumentError: Given listener is null.
 
ArgumentError ArgumentError: Target object cannot be null.
addOnce()method 
public function addOnce(listener:Function):ISlot

Subscribes a one-time listener for this signal. The signal will remove the listener automatically the first time it is called, after the dispatch to all listeners is complete.

Parameters

listener:Function — A function with arguments that matches the value classes dispatched by the signal. If value classes are not specified (e.g. via Signal constructor), dispatch() can be called without arguments.

Returns
ISlot — a ISlot, which contains the Function passed as the parameter

Throws
flash.errors:IllegalOperationError IllegalOperationError: You cannot addOnce() then add() the same listener without removing the relationship first.
 
ArgumentError ArgumentError: Given listener is null.
 
ArgumentError ArgumentError: Target object cannot be null.
addOnceWithPriority()method 
public function addOnceWithPriority(listener:Function, priority:int = 0):ISlot

Subscribes a one-time listener for this signal. The signal will remove the listener automatically the first time it is called, after the dispatch to all listeners is complete.

Parameters

listener:Function — A function with an argument that matches the type of event dispatched by the signal. If eventClass is not specified, the listener and dispatch() can be called without an argument.
 
priority:int (default = 0) — The priority level of the event listener. The priority is designated by a signed 32-bit integer. The higher the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1.

Returns
ISlot — a ISlot, which contains the Function passed as the parameter

Throws
flash.errors:IllegalOperationError IllegalOperationError: You cannot addOnce() then add() the same listener without removing the relationship first.
 
ArgumentError ArgumentError: Given listener is null.
 
ArgumentError ArgumentError: Target object cannot be null.
addWithPriority()method 
public function addWithPriority(listener:Function, priority:int = 0):ISlot

Subscribes a listener for the signal. After you successfully register an event listener, you cannot change its priority through additional calls to add(). To change a listener's priority, you must first call remove(). Then you can register the listener again with the new priority level.

Parameters

listener:Function — A function with an argument that matches the type of event dispatched by the signal. If eventClass is not specified, the listener and dispatch() can be called without an argument.
 
priority:int (default = 0)

Returns
ISlot — a ISlot, which contains the Function passed as the parameter

Throws
flash.errors:IllegalOperationError IllegalOperationError: You cannot addOnce() then add() the same listener without removing the relationship first.
 
ArgumentError ArgumentError: Given listener is null.
 
ArgumentError ArgumentError: Target object cannot be null.
dispatch()method 
public function dispatch(... valueObjects):void

Dispatches an object to listeners.

Parameters

... valueObjects — Any number of parameters to send to listeners. Will be type-checked against valueClasses.


Throws
ArgumentError ArgumentError: Event object expected.
 
ArgumentError ArgumentError: No more than one Event object expected.
 
ArgumentError ArgumentError: Target object cannot be null.
 
ArgumentError ArgumentError: Event object cannot be null.
 
ArgumentError ArgumentError: Event object [event] is not an instance of [eventClass].
 
ArgumentError ArgumentError: Event object has incorrect type. Expected [eventType] but was [event.type].
dispatchEvent()method 
public function dispatchEvent(event:Event):Boolean

Unlike other signals, NativeSignal does not dispatch null because it causes an exception in EventDispatcher. Dispatches an event to listeners.

Parameters

event:Event — An instance of a class that is or extends flash.events.Event.

Returns
Boolean

Throws
ArgumentError ArgumentError: Target object cannot be null.
 
ArgumentError ArgumentError: Event object cannot be null.
 
ArgumentError ArgumentError: Event object [event] is not an instance of [eventClass].
 
ArgumentError ArgumentError: Event object has incorrect type. Expected [eventType] but was [event.type].
registerListenerWithPriority()method 
protected function registerListenerWithPriority(listener:Function, once:Boolean = false, priority:int = 0):ISlot

Parameters

listener:Function
 
once:Boolean (default = false)
 
priority:int (default = 0)

Returns
ISlot
registrationPossible()method 
protected function registrationPossible(listener:Function, once:Boolean):Boolean

Parameters

listener:Function
 
once:Boolean

Returns
Boolean
remove()method 
public function remove(listener:Function):ISlot

Unsubscribes a listener from the signal.

Parameters

listener:Function

Returns
ISlot — a ISlot, which contains the Function passed as the parameter
removeAll()method 
public function removeAll():void

Unsubscribes all listeners from the signal.