There is the base class
Tween nad then multiple utility tweens. Let's start with the base class.
After you create a tween, you use
start() to start the time before calling the function.
finish() to end the function beforehand manually (calls the complete function).
cancel() to delete the tween from the container (doesn't call the complete function).
The constructor has 4 parameters (all optional except the duration).
- The duration in seconds of the period. (aka time between calling the function)
- The type of the Tween (what does after finishing the first loop).
LOOPING will be looping utill you stop or delete it.
PERSIST will loop once every time you call
ONESHOT will call once and then delete iteself from the container (if you want to use it again it must be added to another tweener).
- The function tha is called after the full period. (you can call this function using the
complete atribute if you don't want to stop the tween,
cancel() or 'finish()` (both of them explained above).
- This is a function that, in case that it exists, it's used to modify the internal time. It must contain a single parameter which is a number and will be the current time; and returns another number wich is the new current time.
Here an example of creation a
Tween and adding it to a
Tweener (in this case [and the most common one] a
//somewhere inside a World function
var tween:Tween = new Tween (10, Tween.LOOPING, callback);
//Every 10 seconds 'callback' will be called, untill we finish() it or concel() it.
//this true starts the tween automatically, so we don't need another code line
But it doesn't end here. The real thing with the tweens is that you can make subclasses with a better specific functionality. There already are a lot of usefull ones so i recomend to look the
net.flashpunk.tweeners subpackages (if you want to see how they work you can look the code).
I hope it helped you even if it was a bit. I'm not the best trying to explain things, so sorry if you can't understan it well.