Tuesday, June 24, 2008

About Tween classes and easing methods

Transitions:-

Back: Extends the animation beyond the transition range at one or both ends once to resemble an overflow effect.

Bounce: Adds a bouncing effect within the transition range at one or both ends. The number of bounces relates to the duration--longer durations produce more bounces.

Elastic: Adds an elastic effect that falls outside the transition range at one or both ends. The amount of elasticity is unaffected by the duration.

Regular: Adds slower movement at one or both ends. This feature lets you add a speeding up effect, a slowing down effect, or both.

Strong: Adds slower movement at one or both ends. This effect is similar to Regular easing, but it's more pronounced.

None: Adds an equal movement from start to end without effects, slowing down, or speeding up. This transition is also called a linear transition.

Methods:-
easeIn : Provides the easing effect at the beginning of the transition.

easeOut: Provides the easing effect at the end of the transition.

easeInOut: Provides the easing effect at the beginning and end of the transition.

For Example:

import mx.transitions.Tween;
import mx.transitions.easing.*;
new Tween(ball_mc, "_x", Elastic.easeOut, Stage.width, 0, 3, true);

About continuing animations using the continueTo() method

import mx.transitions.Tween;
import mx.transitions.easing.*;
var ball_tween:Object = new Tween(ball_mc, "_x", Regular.easeIn, 0, 300, 3, true);
ball_tween.onMotionFinished = function() {
ball_tween.continueTo(0, 3);
};

Creating animations that run continuously using yoyo()

var box_tween:Tween = new Tween(box_mc, "_x", Regular.easeInOut, 0, Stage.width, 3, true);
box_tween.onMotionFinished = function() {
box_tween.yoyo();
};

Combining the TransitionManager and Tween classes

import mx.transitions.*;
import mx.transitions.easing.*;
var mcl_obj:Object = new Object();
mcl_obj.onLoadInit = function(target_mc:MovieClip) {
new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true);
TransitionManager.start(target_mc, {type:Fly, direction:Transition.IN, duration:3 easing:Elastic.easeInOut, startPoint:6});
};
var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.addListener(mcl_obj);
my_mcl.loadClip("image1.jpg", this.createEmptyMovieClip("img_mc", this.getNextHighestDepth()));

No comments: