CommandMS
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Known subclasses: | |
| Version: | 1.0 |
| Author: | Francis Bourre |
| Classpath: | com.bourre.commands.CommandMS |
| File last modified: | Wednesday, 31 October 2007, 07:35:29 |
CommandMS allows to store Command objects and to loop their execution at a specified speed in milliseconds.
I encourage in most of cases to use singleton implementation : CommandManagerMS
In the Example below, the specified command will be runned each second :
import com.bourre.commands.*; var t:CommandMS = new CommandMS(); function test(s:String) : Void { trace("hello world"); } t.push( new Delegate(this, test), 1000 );
Summary
Constructor
CommandMS
CommandMS instance.That allows to store Command objects and to loop
their execution at a specified speed in milliseconds.
Instance methods
delay
The command will be executed once.
In this example, the method execution is 3 seconds delayed :
import com.bourre.commands.*; var t:CommandMS = new CommandMS(); function test() : Void; * { trace('hello world'); } t.delay( new Delegate(this, test), 3000 );
getLength
push
The passed command added will be executed in a loop until
you stop it temporarily or remove it definitely.
You must specify time loop duration in milliseconds.
This method returns a String, you can use it later as a hashcode
to stop, restart or remove your command.
Check pushWithName documentation to get more details on this topic.
pushWithName
The passed command added will be executed in a loop until
you stop it temporarily or remove it definitely.
You must specify time loop duration in milliseconds.
It works exactly the same as push excepts it takes String as parameter.
This String will work as a hashcode for further stop (removeWithName),
removal (stopWithName) or restart (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
Usage : t.resume( myCommand );
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 restart it
with resume or resumeWithName methods.
Usage : t.stop(myCommand);
stopWithName
The targeted command won't be executed anymore until you restart 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" );