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,
from
to
. When you set the parameter to
true
false
duration is in seconds. If you set the parameter to
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
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
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.
492
Animation, Filters, and Drawings
instance using the
ball_mc
, you tell Flash that the specified
true
, the duration is the number of
false
Strong.easeIn
"About animation and frame rate"
,
useSeconds
easing method.
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?