transition

Availability

AS2 and AS3.

Usage

... transition:value, ...

Parameters

value:String or Function — The type of transition to use. Different equations can be used, producing different tweening updates based on time spent. You can specify this parameter by their internal string names, as listed on the original transitions list, or use any custom function to have a customized easing (see below for examples and a more in-depth description). The default transition is "easeOutExpo".

Examples

// Slides a MovieClip to _x = 200 using a boring, linear transition (AS2)
Tweener.addTween(myMovieClip, {_x:200, time:1, transition:"linear"});
// Slides a MovieClip to _x = 200 using a more smooth easeOutExpo transition (AS2)
Tweener.addTween(myMovieClip, {_x:200, time:1, transition:"easeOutExpo"});
// Same as above, but using the function reference itself
Tweener.addTween(myMovieClip, {_x:200, time:1, transition:Equations.easeOutExpo}); 
// Same as above, but using a function reference from Flash
Tweener.addTween(myMovieClip, {_x:200, time:1, transition:mx.transitions.easing.Strong.easeOut});
// Creating and using a custom function
var myFunc:Function = function(t:Number, b:Number, c:Number, d:Number):Number {
	var ts:Number=(t/=d)*t;
	var tc:Number=ts*t;
	return b+c*(-97.1975*tc*ts + 257.5975*ts*ts + -234.4*tc + 80*ts + -5*t);
};
Tweener.addTween(myMovieClip, {_x:200, time:1, transition:myFunc});

Notes

If you want to use a custom function as the transition, the function must receive four parameters: current time on the transition, starting tweening value, change needed in that value, and total easing duration (plus an optional object, which will contain any parameter passed as the transitionParams property of new tweenings). During each tweening, the transition function will be continuously called, with the first parameter increasing until it reaches the total duration; it must return the new expected value.

It's important to notice that this function follows the classic easing equation format, as used on Robert Penner's original easing equations, or Flash's own transition equations; as such, all mx.effects.easing equations (for AS3) or mx.transitions (AS2) also work.

See Tweener's caurina/transitions/Equations.as file for some examples on how this work.

A good custom easing equation generator can be found here.

See also

registerTransition, transitionParams