EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 492

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
492 Animation, Filters, and Drawings
Instead of using seconds, you can fade the symbol over a few frames. To set the duration in
frames instead of seconds in the Tween class, you change the final parameter,
useSeconds,
from
true to false. When you set the parameter to true, you tell Flash that the specified
duration is in seconds. If you set the parameter to
false, the duration is the number of
frames you want to use for the tween. The next procedure shows how to set a tween to frames
instead of seconds.
To set a duration of frames instead of seconds:
1. Create a new document, and call it framesTween.fla.
2. Create a movie clip on the Stage.
3. Select the movie clip instance, and type ball_mc into the Instance Name text box in the
Property inspector.
4. Select Frame 1 of the Timeline, and add the following code in the Actions panel:
import mx.transitions.Tween;
import mx.transitions.easing.*;
new Tween(ball_mc, "_alpha", Strong.easeIn, 100, 0, 24, false);
This code fades out the ball_mc instance using the Strong.easeIn easing method.
Instead of fading the instance for three seconds, it fades the instance across 24 frames.
5. Select Control > Test Movie to see the animation.
Wait a moment, then the instance fades out across 24 frames.
6. Return to the authoring environment and open the Property inspector.
7. Change the document’s frame rate to 24 fps.
If you increase the frame rate of your FLA file, you see the instance fade out sooner. For
information on animation and frame rate, see About animation and frame rate”
on page 471.
Using frames instead of seconds offers more flexibility, but remember that the duration relates
to the frame rate of the current Flash document. If your Flash document uses a frame rate of
12 frames per second (fps), the previous code snippet fades the instance over two seconds
(24 frames/12 fps = 2 seconds). However, if your frame rate is 24 fps, the same code fades the
instance over one second (24 frames/24 fps = 1 second). If you use frames to measure
duration, you can significantly change the speed of your animation when you change the
document’s frame rate, without modifying your ActionScript.
The Tween class has several more useful features. For example, you can write an event handler
that triggers when the animation completes, as the next procedure shows.

Table of Contents

Related product manuals