As3 Tween Class and Easing Class

Hi,


In action script tween class was verry important for programmers, because programmers can do animation without designers help :)

Here I am describing about basics of tween class in as3.

To use tween class we should need to import two classes into file, those are

"fl.transitions.Tween","fl.transitions.easing.*".

import fl.transitions.Tween;
import fl.transitions.easing;

Now you can use "tween" functions otherwise it will show error :)

To animate movie clip "obj" in "x" direction from "250" to "500" withing 1 secon we have to write following code:


var objTween:Tween = new Tween(obj, "x", Elastic.easeOut, 250, 500, 1, true);


Here "ObjTween" is a Tween variable, by using this we can control tween animation, I mean we can stop,extends animation, start animation and reverse animation.

In above code "x" indicates x-direction, "Elastic.easeOut" it's type of animation. we can use several types like "Elastic.easeIn", "Regular.easeOut", "Regular.easeIn" etc...


"250,500" intimates "from" and "to" positions. ",1" intimates time period.


We can write events for it, we can run a function, when tween start or when tween end, when tween change, etc..

To write we need to import class "import fl.transitions.TweenEvent".

objTween.addEventListener(TweenEvent.MOTION_FINISH, motionFinish);

function motionFinish(event:TweenEvent)
{
    trace("motion finished");
}




Total Code:

import fl.transitions.Tween;
import fl.transitions.easing;
var objTween:Tween = new Tween(obj, "x", Elastic.easeOut, 250, 500, 1, true);
objTween.addEventListener(TweenEvent.MOTION_FINISH, motionFinish);
function motionFinish(event:TweenEvent)
{
    trace("motion finished");
}




If u need more assistance u can find here:

Tween Class: http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/fl/transitions/Tween.html

Easing Class: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/transitions/easing/package-detail.html