org.as2lib.core.BasicClass +--org.as2lib.env.event.impulse.AbstractImpulse +--org.as2lib.env.event.impulse.FrameImpulse
Impulse
FrameImpulse
is a implementation of Impulse for a impulse
that gets executed at a the Frame onEnterFrame
event.
FrameImpulse
supports static methods for easy connecting to a
FrameImpulse.
Note: Those methods can not be named in the same way as the public methods
are named because of a restriction in Macromedias compiler.
Example:
import org.as2lib.app.exec.Executable;
import org.as2lib.env.event.impulse.FrameImpulseListener;
import org.as2lib.app.exec.FrameImpulse;
class com.domain.FrameTracer implements FrameImpulseListener {
private var prefix:String;
private var postfix:String;
public function FrameTracer(prefix:String, postfix:String) {
this.prefix = prefix;
this.postfix = postfix;
FrameImpulse.getInstance().addFrameImpulseListener(this);
}
public function onFrameImpulse(impulse:FrameImpulse):Void {
trace(prefix+_root._currentframe+postfix);
}
}
addAllImpulseListeners(), addAllListeners(), addImpulseListener(), connectAllExecutables(), connectExecutable(), disconnectAllExecutables(), disconnectExecutable(), getAllConnectedExecutables(), getAllImpulseListeners(), hasImpulseListener(), isExecutableConnected(), removeAllImpulseListeners(), removeImpulseListener()
static public function getInstance(Void):FrameImpulse
Getter for a instance of a FrameImpulse.
Generates a new FrameImpulse if no FrameImpulse has been set.
FrameImpulse
instance.
public function setTimeline(timeline:MovieClip):Void
Sets a new Timeline as main timeline for the MovieClip.
timeline | Timeline to be used for the frame event. |
IllegalArgumentException | if onEnterFrame has already been used in the timeline. |
public function getTimeline(Void):MovieClip
Getter for the currently listening timeline.
This method creates a new timeline in root and listenes to it if no timeline has been set.
Timeline that is currently used
FatalExeception | if a Timeline could not be generated on the fly. |
public function addListener(listener):Void
Method to add any supported listener to the FrameImpulse.
Adds a listener to the FrameImpulse. The listener will be informed on each frame change.
Example:
import org.as2lib.env.event.impulse.Impulse;
import org.as2lib.env.event.impulse.FrameImpulse;
function test(impulse:Impulse) {
trace("Test called: "+impulse+" at "+getTimer()+"ms");
}
var impulse:Impulse = FrameImpulse.getInstance();
impulse.addListener(new Call(this, test));
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. |
addListener() in org.as2lib.env.event.impulse.AbstractImpulse
public function addFrameImpulseListener(listener:FrameImpulseListener):Void
Methode to add a FrameImpulseListener as listener to the FrameImpulse.
Some parts of the code get better readable if you use a complete
clear name like "onFrameImpulse" to define your code. With
.addFrameImpulseListener
you can add a listener that specially
listens only to this naming of the same event that will be executed as
"onImpulse" or "execute".
Example:
Listener:
import org.as2lib.env.event.impulse.FrameImpulseListener;
import org.as2lib.env.event.impulse.FrameImpulse;
class TraceTimeImpulseListener implements FrameImpulseListener {
public function onFrameImpulse(impulse:FrameImpulse):Void {
trace("Frameimpulse executed at "+getTimer());
}
}
Usage:
import org.as2lib.env.event.impulse.FrameImpulse;
var impulse:FrameImpulse = FrameImpulse.getInstance();
impulse.addFrameImpulseListener(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. |
removeListener() in org.as2lib.env.event.impulse.AbstractImpulse
public function removeFrameImpulseListener(listener:FrameImpulseListener):Void
Removes a FrameImpulseListener from listening to the events.
The passed listener will be removed from listening to any event
(not only to from listening to onFrameImpulse
).
listener | Listener to be removed. |
public function getAllListeners(Void):Array
Getter for the list of all added listeners.
This method returns a list of all listeners added with eighter connectExecutable, addListener addImpulseListener or addFrameImpulseListener
List that contains all added listeners.
getAllListeners() in org.as2lib.env.event.impulse.AbstractImpulse
public function getAllFrameImpulseListeners(Void):Array
Getter for the list of all added FrameImpulseListeners.
List that contains all added FrameImpulseListeners.
public function removeAllListeners(Void):Void
Removes all added listeners from listening to the FrameImpulse.
IllegalArgumentException | if the |
removeAllListeners() in org.as2lib.env.event.impulse.AbstractImpulse
public function hasListener(listener):Boolean
Returns true
if passed-in listener
has been added.
listener | the listener to check whether it has been added |
true
if the listener
has been added
hasListener() in org.as2lib.env.event.impulse.AbstractImpulse
public function addAllFrameImpulseListeners(listeners:Array):Void
Adds a list of FrameImpulseListeners 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 removeAllFrameImpulseListeners(Void):Void
Removes all added FrameImpulseListeners from listening to any event.
public function hasFrameImpulseListener(listener:FrameImpulseListener):Boolean
Checks if a certain FrameImpulseListener has been added as listener.
listener | Listener to be checked if it has been added. |
true
if the certain listener has been added.