Class org.as2lib.env.event.impulse.FrameImpulse

org.as2lib.core.BasicClass
   +--org.as2lib.env.event.impulse.AbstractImpulse
      +--org.as2lib.env.event.impulse.FrameImpulse

Implemented Interfaces

Impulse

Description

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); } }

Method Index

addAllFrameImpulseListeners(), addFrameImpulseListener(), addListener(), getAllFrameImpulseListeners(), getAllListeners(), getInstance(), getTimeline(), hasFrameImpulseListener(), hasListener(), removeAllFrameImpulseListeners(), removeAllListeners(), removeFrameImpulseListener(), removeListener(), setTimeline()

Inherited from AbstractImpulse

addAllImpulseListeners(), addAllListeners(), addImpulseListener(), connectAllExecutables(), connectExecutable(), disconnectAllExecutables(), disconnectExecutable(), getAllConnectedExecutables(), getAllImpulseListeners(), hasImpulseListener(), isExecutableConnected(), removeAllImpulseListeners(), removeImpulseListener()

Inherited from BasicClass

toString()

Method Detail

getInstance

static public function getInstance(Void):FrameImpulse

Getter for a instance of a FrameImpulse.

Generates a new FrameImpulse if no FrameImpulse has been set.

Return

FrameImpulse instance.

setTimeline

public function setTimeline(timeline:MovieClip):Void

Sets a new Timeline as main timeline for the MovieClip.

Parameters

timelineTimeline to be used for the frame event.

Throws

IllegalArgumentExceptionif onEnterFrame has already been used in the timeline.

getTimeline

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.

Return

Timeline that is currently used

Throws

FatalExeceptionif a Timeline could not be generated on the fly.

addListener

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).

Parameters

listenerto be added.

Throws

IllegalArgumentExceptionif the listener doesn't match any type.

Overrides

addListener() in org.as2lib.env.event.impulse.AbstractImpulse

addFrameImpulseListener

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());

Parameters

listenerListener to be added.

removeListener

public function removeListener(listener):Void

Removes a listener of any type that might be added.

Parameters

listenerListener to be removed.

Throws

IllegalArgumentExceptionif you pass a listener that is of a illegal type.

Overrides

removeListener() in org.as2lib.env.event.impulse.AbstractImpulse

removeFrameImpulseListener

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).

Parameters

listenerListener to be removed.

getAllListeners

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

Return

List that contains all added listeners.

Overrides

getAllListeners() in org.as2lib.env.event.impulse.AbstractImpulse

getAllFrameImpulseListeners

public function getAllFrameImpulseListeners(Void):Array

Getter for the list of all added FrameImpulseListeners.

Return

List that contains all added FrameImpulseListeners.

removeAllListeners

public function removeAllListeners(Void):Void

Removes all added listeners from listening to the FrameImpulse.

Throws

IllegalArgumentExceptionif the

Overrides

removeAllListeners() in org.as2lib.env.event.impulse.AbstractImpulse

hasListener

public function hasListener(listener):Boolean

Returns true if passed-in listener has been added.

Parameters

listenerthe listener to check whether it has been added

Return

true if the listener has been added

Overrides

hasListener() in org.as2lib.env.event.impulse.AbstractImpulse

addAllFrameImpulseListeners

public function addAllFrameImpulseListeners(listeners:Array):Void

Adds a list of FrameImpulseListeners as listener to the events.

Parameters

listenersList of all listeners to add.

Throws

IllegalArgumentExceptionif one listener didn't match to any listener type.

removeAllFrameImpulseListeners

public function removeAllFrameImpulseListeners(Void):Void

Removes all added FrameImpulseListeners from listening to any event.

hasFrameImpulseListener

public function hasFrameImpulseListener(listener:FrameImpulseListener):Boolean

Checks if a certain FrameImpulseListener has been added as listener.

Parameters

listenerListener to be checked if it has been added.

Return

true if the certain listener has been added.