All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scaffold.libs_as.org.osflash.signals.Signal.as Maven / Gradle / Ivy

package org.osflash.signals
{
	/**
	 * Allows the valueClasses to be set in MXML, e.g.
	 * {[String, uint]}
	 */
	[DefaultProperty("valueClasses")]
	/**
	 * Signal dispatches events to multiple listeners.
	 * It is inspired by C# events and delegates, and by
	 * signals and slots
	 * in Qt.
	 * A Signal adds event dispatching functionality through composition and interfaces,
	 * rather than inheriting from a dispatcher.
	 * 

* Project home: http://github.com/robertpenner/as3-signals/ */ public class Signal extends OnceSignal implements ISignal { /** * Creates a Signal instance to dispatch value objects. * @param valueClasses Any number of class references that enable type checks in dispatch(). * For example, new Signal(String, uint) * would allow: signal.dispatch("the Answer", 42) * but not: signal.dispatch(true, 42.5) * nor: signal.dispatch() * * NOTE: In AS3, subclasses cannot call super.apply(null, valueClasses), * but this constructor has logic to support super(valueClasses). */ public function Signal( ...valueClasses ) { // Cannot use super.apply(null, valueClasses), so allow the subclass to call super(valueClasses). valueClasses = (valueClasses.length == 1 && valueClasses[ 0 ] is Array) ? valueClasses[ 0 ] : valueClasses; super( valueClasses ); } /** * @inheritDoc * @throws flash.errors.IllegalOperationError IllegalOperationError: You cannot addOnce() then add() the same listener without removing the relationship first. * @throws ArgumentError ArgumentError: Given listener is null. */ public function add( listener : Function ) : ISlot { return registerListener( listener ); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy