CommandFPS
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Implements: | |
| Known subclasses: | |
| Version: | 1.0 |
| Author: | Francis Bourre |
| Classpath: | com.bourre.commands.CommandFPS |
| File last modified: | Wednesday, 31 October 2007, 07:35:29 |
CommandFPS allows to store Command objects and to execute each oneat each frame displayed by the player.
If your animation framerate is 31 fps, each added command
will have its execute method triggered 31 times per second.
I encourage in most of cases to use singleton implementation : CommandManagerFPS
See below a basical example to understand the mechanism :
import com.bourre.commands.*; var t:CommandFPS = new CommandFPS(); var d:Delegate = new Delegate(this, test); var i:Number = 0; function test(s:String) : Void { trace("hello world"); i++; if (i >= 10) t.remove(d); } t.push( d );
Summary
Constructor
Instance methods
delay
The passed command will be executed once.
import com.bourre.commands.*; var t:CommandFPS = new CommandFPS(); function test() : Void; * { trace("hello world"); } t.delay( new Delegate(this, test) );
getLength
push
The passed command added will be executed each frame until you stop it temporarily
or remove it definitely.
This method returns a String, you can use it later as a hashcode
to stop, resume or remove your command.
Check pushWithName documentation to get more details on this topic.
pushWithName
The passed command added will be executed each frame until you stop it temporarily
or remove it definitely from CommandFPS instance.
It works exactly the same as push excepts it takes String as parameter.
This String will work as a hashcode for further stop (pushWithName),
removal (stop) or resume (resumeWithName).
If you provide an existing key, it will remove the associated command without any warning.
Another note, try to use this feature only when its absolutely required.
Generally, be careful about your design and objects encapsulation.
Don't make global references when it's not needed.
remove
The passed command won't be executed anymore.
Usage : t.remove(myCommand);
removeAll
Each command added will be removed, it means that they won't be executed anymore.
Warning, because you can't undo this method's behaviour.
removeWithName
The passed command won't be executed anymore.
It works exactly the same as remove excepts it takes String as parameter.
You must pass a valid key to ensure it works.
The expected key is the String returned by push method while command addition.
Usage : t.removeWithName( "key" );
resume
resumeWithName
It works exactly the same as resume excepts it takes String as parameter.
You must pass a valid key to ensure that works.
The expected key is the String returned by push method while command addition.
Usage : t.resume( "key" );
stop
The targeted command won't be executed anymore until you resume it
with resume or resumeWithName methods.
Usage : t.stop(myCommand);
stopWithName
The targeted command won't be executed anymore until you resume it
with resume or resumeWithName methods.
It works exactly the same as stop excepts it takes String as parameter.
You must pass a valid key to ensure that works.
The expected key is the String returned by push method while command addition.
Usage : t.stopWithName( "key" );
toString
Event handlers
onEnterFrame
That's the public callback of com.bourre.transitions.FBeacon used internally to run stored commands on each frame.