I made a useful AS3 ActionManager class that ques up a set of actions, each lasting for a certain number of frames.
To use the ActionManager class properly, you need to create a sub-class that defines the necessary methods.
Here’s an example of how you would set up an ActionManager:
(In this case ActionQue extends ActionManager; both files are attached to this post)
var lol:ActionQue = new ActionQue()
lol.action(“doit”,10,20,“hi”);
lol.action(“hack”,5,99,“lol”);
lol.action(“gocrazy”,20);
lol.action(“hack”,5);
lol.begin()
Basically, the first two parameters of the action() method are required; the first defines the method (in string) to perform, and the second defines the duration in frames of that action. As for the rest; you can add any additional parameters to associate with an action; these parameters will be stored in an array and they will be removed after the action has finished executing… Therefore, the [0] index of the array is always the action that is currently being executed.
The begin() method instructs the class to start performing each action in turn until there is nothing more to do.
You can have many instances of “ActionQue” run at the same time in case you want to synchronize actions.
I came up with the idea for this class by wanting to make an animation engine; I was thinking of making a platform-game environment that recoded each of my “actions” per frame as a string, then store the strings in an array, then once I stopped playing, it would display a que of all my actions and their durations in order… Then I thought of using an ActionManager to use that que to reproduce the same actions in the form of an animation.
… The actions could be as simple as; “moveToLeft” or as complex as “zoomIn” or even “produceTheSoundOhWithMouth” etc…
Anyway, here are the files (attached):