Regular Easing

Regular Easing

Flash CS4 ActionScript 3.0 Tutorial


How to Vary the Speed and Duration when Applying a Flash ActionScript Tween



Easing is used with transitions and tweening. For more information, see topics, Blinds Transition, Fade Transition, Fly Transition, Iris Transition, Photo Transition, Pixel Dissolve Transition, Rotate Transition, Squeeze Transition, Wipe Transition, Zoom Transition, and Tweening Object Properties. There are several easing choices (i.e., Back, Bounce, etc) and multiple ways to apply the ease (i.e., easeIn, easeOut, or easeInOut).

In this example we will demo the Strong ease on the rotation property. You can change the rotation parameter to any other object property (i.e., alpha, height, rotationX, rotationY, rotationZ, scaleX, scaleY, width, x or y). To make things even more exciting, consider duplicating your tween and assigning the new tween a new variable name. In the second tween, change the property so now the object tweens two properties at the same time.

Tutorial Elements

Movie Symbol with instance name blueBar_mc


Step One

Add a Movie Symbol to the stage and select the symbol with the Selection tool (v key).

Step Two

Open the Properties panel (Cmd/F3 (PC-Ctrl/F3)) and type in the name blueBar_mc for the Instance Name.

Step Three

Add a new layer called Actions.

Step Four

Option double-click (PC - Alt double-click) the keyframe in the Actions layer to open the ActionScript panel.

Step Five

Copy/Paste the following code to the ActionScript panel.

import fl.transitions.Tween;

import fl.transitions.easing.*;

var adjRotation:Tween = new Tween (blueBar_mc, "rotation", Regular.easeInOut, 0, 720, 3, true);

//Tween Options: instance name, "object property", ease type, start value, end value, duration, true = seconds false = frames;

Step Six

Test your movie by pressing Cmd/Return (PC - Ctrl/Enter). The object is placed on the stage with a 0 degree rotation. It then gently starts to turn and rotates 720 degrees in a clockwise direction. The object slowly stops at it's final location.

Dissecting the Code

The first two lines import the Tween Class and easing package into your document. The var line establishes a new Tween. It affects the blueBar_mc and targets the object's rotation property. The ease is set to Regular and it happens in the beginning and in the end.

The object starts in it's normal rest position. It then makes its 720 degree rotation by slowly starting and gently stopping. It occurs over 3 seconds. By setting the last parameter to true, the values are in seconds, not frames.

More Ease Options

You can substitute easeInOut (beginning and end) with easeIn (beginning) or easeOut (end). You can always replace Regular with None to cancel the Regular feature.

Tweens and Animated Movie Symbols

Consider using an animated Movie Symbol in your Tweens. The animation plays while the Tween creates additional movement.

Stopping and Starting a Tween

At times you may want to stop, start or start your Tween back at the beginning. Since you assigned a variable to the Tween, you can supply the variable with specific instructions. For instance, the following lines of code control the Tween in our example.


//stops the tween


//resumes playing the tween


//starts the tween at the beginning