AddThis Social Bookmark Button
 Dynamic tweening with the Tween and Easing class (part 2)

The Easing classes parameters

There is 5 easing classes which are:

Transition
Description
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.

Each of these classes above has three easing methods :

Method

Description

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.

A bit of practise after the theory

Now that we have the theory in the pocket let's try to move a movie clip across the stage using the _x and the _y properties with the Tween and the Easing classes. First let's have a look at the code below:

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

playAnimation.onPress = function() {

myTweeningX = new Tween(hat, "_x",Bounce.easeOut, 33, 418, 2, true);
myTweeningY = new Tween(hat, "_y",Bounce.easeIn, 34, 166, 2, true);

myTweeningX.FPS = 40;
myTweeningY.FPS = 40;

};

In the example above we are animating the _x and _y properties of the "hat" movie clip over 2 seconds. You can see that we can achieve some interesting effect with a tiny amount of code. Creating that animation using the normal authoring time motion tween system would take a lot longer.

We use the FPS property to smoothen the animation, the frame rate of the main movie is still set at 12 frames per second.

Don't forget that you can tween all properties than can normally be tweened at authoring time using the normal timeline method.

Continue to next page...


AddThis Social Bookmark Button
If you think this page is providing useful information, don't hesitate to leave a comment.
flashvalley
 
Copyright ©2006-2008 flashvalley.com - All rights reserved