org.as2lib.core.BasicClass +--org.as2lib.env.event.impulse.AbstractImpulse
AbstractImpulse
is a helper class that contains shared API to be used
by different Impulse Implementations.
public function connectExecutable(exe:Executable):Void
Connects a executable as listener to the frame execution.
exe | Executable to be added as listener |
public function addAllListeners(listeners:Array):Void
Adds a list of listeners to listen to the impulse events.
listeners | List of listeners to be added. |
IllegalArgumentException | if a listener could not be added. |
public function addListener(listener):Void
Method to add any supported listener to the FrameImpulse.
Adds a listener to the Impulse. The listener will be informed on each frame change.
Note: If a certain listener implements more than one supported event it will listen to all of them at one execution (execute, onFrameImpulse, onImpulse).
listener | to be added. |
IllegalArgumentException | if the listener doesn't match any type. |
public function addImpulseListener(listener:ImpulseListener):Void
Methode to add a ImpulseListener as listener to the Impulse.
Some parts of the code get better readable if you use a complete
clear name like "onImpulse" to define your code. With
.addImpulseListener
you can add a listener that specially
listens only to this naming of the same event that will be executed as
"execute".
Example:
Listener:
import org.as2lib.env.event.impulse.ImpulseListener;
import org.as2lib.env.event.impulse.Impulse;
class TraceTimeImpulseListener implements ImpulseListener {
public function onImpulse(impulse:Impulse):Void {
trace("Impulse executed at "+getTimer());
}
}
Usage:
import org.as2lib.env.event.impulse.FrameImpulse;
var impulse:FrameImpulse = FrameImpulse.getInstance();
impulse.addImpulseListener(new TraceTimeImpulseListener());
listener | Listener to be added. |
public function removeListener(listener):Void
Removes a listener of any type that might be added.
listener | Listener to be removed. |
IllegalArgumentException | if you pass a listener that is of a illegal type. |
public function removeImpulseListener(listener:ImpulseListener):Void
Removes a ImpulseListener from listening to the impulse.
listener | ImpulseListener to remove from listening. |
public function removeAllListeners(Void):Void
Removes all added Listeners from listening to the impulse.
public function removeAllImpulseListeners(Void):Void
Removes all added ImpulseListeners from listening to the impulse.
public function disconnectAllExecutables(Void):Void
Disconnects all connected Executables from the impulse.
public function getAllListeners(Void):Array
Getter for the list of all added listeners.
This method returns a list of all listeners added with eihter connectExecutable, addListener or addImpulseListener
List that contains all added listeners.
public function getAllConnectedExecutables(Void):Array
Getter for the list of all connected Executables.
List that contains all connected Executables.
public function getAllImpulseListeners(Void):Array
Getter for the list of all added ImpulseListeners.
List that contains all added ImpulseListeners.
public function addAllImpulseListeners(listeners:Array):Void
Adds a list of ImpulseListeners as listener to the events.
listeners | List of all listeners to add. |
IllegalArgumentException | if one listener didn't match to any listener type. |
public function connectAllExecutables(executables:Array):Void
Connects a list of Executabless to the impulse.
IllegalArgumentException | if one listener didn't match to any listener type. |
public function hasListener(listener):Boolean
Validates if a certain listener of any type is currently added to the impulse.
listener | Listener to be validated. |
true
if the certain executable is connected.
public function hasImpulseListener(listener:ImpulseListener):Boolean
Validates if a certain ImpulseListener is currently added to the impulse.
listener | ImpulseListener to be validated. |
true
if the certain executable is connected.
public function isExecutableConnected(exe:Executable):Boolean
Validates if a certain Executable is currently connected to the impulse.
exe | Executable to be validated. |
true
if the certain executable is connected.