Thursday, July 12, 2007

Tween Class

// I always forget the exact syntax for this, so here it is

import mx.transitions.Tween;
import mx.transitions.easing.*;

var tweenName:Tween = new Tween(load_mc,"_alpha",Strong.easeOut,load_mc._alpha,100,1, true );

tweenName.onMotionFinished = function{
var newTween:Tween = new Tween(load_mc,"_alpha",Strong.easeOut,load_mc._alpha,100,1, true );
}

Here are all the tween possibilities:
1.Back – Extends the animation over one or both ends of the tween.
2.Bounce – Creates a bouncing effect in the tween at one or both ends.
3.Elastic – Creates a mixture of the bounce and back classes. The animation is extended over and bounces back at one or both ends of the Tween.
4.Regular – Slower motion at one or both ends of the tween.
5.Strong – Similar to regular but is more pronounced when combined with the various easing methods.
6.None – A simple linear transition from a to b.

These six easing classes each have three methods to control the ease:
1.easeIn – The ease is applied only at the start of the tween.
2.easeOut – The ease is applied only at the end of the tween.
3.easeInOut – The ease is applied at both the beginning and end of the tween.

More stuff:
Tween.stop() does what it says, it tells the tween to stop at its current position.
Tween.resume() tells the tween to resume playback from its current position, this method is used after invoking the .stop() method.
Tween.continueTo(finish, duration) tells the tween to continue it's animation to a new point starting from its current position.
Tween.start() tells the tween to start playback from the initial starting point, this is not the same as .resume().
Tween.fforward() tells the tween to stop at the end value of the animation.
Tween.nextFrame() tells the tween to go to the next frame.
Tween.preFrame() tells the tween to go back to the previous frame.
Tween.rewind() tells the tween to go back and stop at its starting point.
Tween.yoyo() tells the animation to play in reverse.

.onMotionChanged - continuously triggered when the animation is running.
.onMotionFinished - triggered when the animation is finished.
.onMotionResumed - triggered when the .resume() method is called to resume the animation after being stopped.
.onMotionStarted - triggered when the animation is initiated using the .start() or the .yoyo() method. The code will not be triggered the first time the animation is played when the tween is created.
.onMotionStopped - triggered when the .stop() is called.

No comments: