| Package | org.osflash.signals.natives |
| Class | public class NativeMappedSignal |
| Inheritance | NativeMappedSignal NativeRelaySignal Signal OnceSignal Object |
The NativeMappedSignal class is used to map/transform a native Event, relayed from an IEventDispatcher, into other forms of data, which are dispatched to all listeners.
This can be used to form a border where native flash Events do not cross.
Default MXML PropertyvalueClasses
| Property | Defined By | ||
|---|---|---|---|
| eventClass : Class [override]
The class of event permitted to be dispatched. | NativeMappedSignal | ||
![]() | eventType : String
The type of event permitted to be dispatched. | NativeRelaySignal | |
![]() | numListeners : uint [read-only] The current number of listeners for the signal. | OnceSignal | |
![]() | target : IEventDispatcher
The object considered the source of the dispatched events. | NativeRelaySignal | |
| valueClasses : Array [override]
| NativeMappedSignal | ||
| Property | Defined By | ||
|---|---|---|---|
![]() | _eventClass : Class | NativeRelaySignal | |
![]() | _eventType : String | NativeRelaySignal | |
| mappingFunction : Function [read-only] | NativeMappedSignal | ||
![]() | slots : SlotList | OnceSignal | |
![]() | _target : IEventDispatcher | NativeRelaySignal | |
![]() | _valueClasses : Array | OnceSignal | |
| Method | Defined By | ||
|---|---|---|---|
NativeMappedSignal(target:IEventDispatcher, eventType:String, eventClass:Class = null, ... mappedTypes)
Creates a new NativeMappedSignal instance to map/transform a native Event,
relayed from an IEventDispatcher, into other forms of data,
which are dispatched to all listeners. | NativeMappedSignal | ||
![]() | [override]
Subscribes a listener for the signal. | NativeRelaySignal | |
![]() | [override]
Subscribes a one-time listener for this signal. | NativeRelaySignal | |
![]() | addOnceWithPriority(listener:Function, priority:int = 0):ISlot
Subscribes a one-time listener for this signal. | NativeRelaySignal | |
![]() | addWithPriority(listener:Function, priority:int = 0):ISlot
Subscribes a listener for the signal. | NativeRelaySignal | |
![]() | dispatch(... valueObjects):void [override]
Dispatches an object to listeners. | NativeRelaySignal | |
dispatchEvent(event:Event):Boolean [override] | NativeMappedSignal | ||
mapTo(... objectListOrFunction):NativeMappedSignal
Sets the mapping function or literal object list. | NativeMappedSignal | ||
![]() | [override]
Unsubscribes a listener from the signal. | NativeRelaySignal | |
![]() | removeAll():void [override]
Unsubscribes all listeners from the signal. | NativeRelaySignal | |
| Method | Defined By | ||
|---|---|---|---|
mapEvent(eventFromTarget:Event):Object
For usage without extension, instances of NativeMappedSignal that are dispatching any values ( valueClasses.length > 0 ),
needs to be provided with a either a mapping function or a list of object literals. | NativeMappedSignal | ||
onNativeEvent(event:Event):void [override] | NativeMappedSignal | ||
![]() | registerListener(listener:Function, once:Boolean = false):ISlot | OnceSignal | |
![]() | registerListenerWithPriority(listener:Function, once:Boolean = false, priority:int = 0):ISlot | NativeRelaySignal | |
![]() | registrationPossible(listener:Function, once:Boolean):Boolean | OnceSignal | |
| eventClass | property |
eventClass:Class[override] The class of event permitted to be dispatched. Will be flash.events.Event or a subclass.
public function get eventClass():Class public function set eventClass(value:Class):void| mappingFunction | property |
mappingFunction:Function [read-only] protected function get mappingFunction():Function| valueClasses | property |
valueClasses:Array[override]
public function get valueClasses():Array public function set valueClasses(value:Array):voidArgumentError — ArgumentError: Invalid valueClasses argument: item at index should be a Class but was not.
|
| NativeMappedSignal | () | Constructor |
public function NativeMappedSignal(target:IEventDispatcher, eventType:String, eventClass:Class = null, ... mappedTypes)Creates a new NativeMappedSignal instance to map/transform a native Event, relayed from an IEventDispatcher, into other forms of data, which are dispatched to all listeners.
Parameterstarget:IEventDispatcher — An object that implements the flash.events.IEventDispatcher interface.
| |
eventType:String — The event string name that would normally be passed to IEventDispatcher.addEventListener().
| |
eventClass:Class (default = null) — An optional class reference that enables an event type check in dispatch().
| |
... mappedTypes — an optional list of types that enables the checking of the types mapped from an Event.
|
| dispatchEvent | () | method |
override public function dispatchEvent(event:Event):BooleanParameters
event:Event |
Boolean |
| mapEvent | () | method |
protected function mapEvent(eventFromTarget:Event):Object
For usage without extension, instances of NativeMappedSignal that are dispatching any values ( valueClasses.length > 0 ),
needs to be provided with a either a mapping function or a list of object literals.
See mapTo for more info.
Subclasses could override this one instead of letting the environment set the mapTo,
MAKE SURE to also override mapTo(...) if it should not be allowed.
Parameters
eventFromTarget:Event |
Object — An object or Array of objects mapped from an Event. The mapping of Event to data will be performed by the mapping function
if it is set. A list of object literals can also be supplied in place of the mapping function.
If no mapping function or object literals are supplied then an empty Array is returned or
if valueClasses.length > 0 an ArgumentError is thrown.
|
See also
| mapTo | () | method |
public function mapTo(... objectListOrFunction):NativeMappedSignalSets the mapping function or literal object list. If the argument is a list of object literals then this list is dispatched to listeners.
signal = new NativeMappedSignal(button, MouseEvent.CLICK, MouseEvent, String).mapTo("ping")
signal.add(function(arg:String):void { trace(arg) }) // prints "ping"
signal = new NativeMappedSignal(button, MouseEvent.CLICK, MouseEvent, String, int, Number).mapTo("ping", 3, 3.1415)
signal.add(function(arg1:String, arg2:int, arg3:Number):void { trace(arg1, arg2, arg3) }) // prints "ping", 3, 3.1415
signal = new NativeMappedSignal(button, MouseEvent.CLICK, MouseEvent, String).mapTo(function():void {
return "ping"
})
signal.add(function(arg:String):void { trace(arg) }) // prints "ping"
signal = new NativeMappedSignal(button, MouseEvent.CLICK, MouseEvent, String, int, Number).mapTo(function():void {
return ["ping", 3, 3.1415]
})
signal.add(function(arg1:String, arg2:int, arg3:Number):void { trace(arg1, arg2, arg3) }) // prints "ping", 3, 3.1415
signal = new NativeMappedSignal(button, MouseEvent.CLICK, MouseEvent, Point).mapTo(function(event:MouseEvent):void {
return new Point(event.localX, event.localY)
})
signal.add(function(arg:Point):void { trace(arg) }) // prints "(x=128, y=256)"
Parameters
... objectListOrFunction — This can either be a list of object literals or a function that returns list of objects.
|
NativeMappedSignal — The NativeMappedSignal object this method was called on. This allows the Signal to be defined and mapped in one statement.
|
ArgumentError — ArgumentError: Mapping function needs zero or one arguments of type Event
|
| onNativeEvent | () | method |
override protected function onNativeEvent(event:Event):voidParameters
event:Event |