Import and use the Tween class
Create a new document and name it easetween.fla.
Create a movie clip on the stage.
Select the movie clip instance and type BALL_MC in the Instance Name text box in the property inspector.
Select Frame 1th in the timeline and add the following code to the Actions panel:
The code is as follows |
Copy Code |
Import Mx.transitions.Tween; Import mx.transitions.easing.*; New Tween (BALL_MC, "_x", Elastic.easeout, Stage.width, 0, 3, true); |
This code example uses two import statements. The first statement imports only the Mx.transitions.Tween class, and the second import statement uses the wildcard (*) shortcut to import the six easing classes one at a time by using a single easing class with the line code. The second statement imports an entire class package.
Tween class Fade Instance
Create a new document and name it fadetween.fla.
Create a movie clip on the stage.
Select the movie clip instance and type BALL_MC in the Instance Name text box in the property inspector.
Select Frame 1th in the timeline and add the following code to the Actions panel:
The code is as follows |
Copy Code |
Import Mx.transitions.Tween; Import mx.transitions.easing.*; New Tween (BALL_MC, "_alpha", Strong.easein, 0, 3, true); |
Now, BALL_MC is not moving on the stage, but is fading from 100% to full transparency in three seconds. To make the symbol fade out faster, change the duration parameter from 3 to 1 or 2.
Select Control > Test movie to view the animation.
If you change the frame rate of a document, the animation will play more smoothly.