496
Animation, Filters, and Drawings
6.
Test the animation again (Control > Test Movie).
Now, the box stops easing before it goes off the boundaries of the Stage.
Combining the TransitionManager and
Tween classes
You can generate interesting effects when you combine the TransitionManager and Tween
classes. You can use the TransitionManager class to move a movie clip along the
x
-axis while
you adjust the same clip’s
_alpha
property using the Tween class. Each class can use a
different easing method, which means you have many animation possibilities for objects in
your SWF files. You can take advantage of the
continueTo()
and
yoyo()
methods in the
Tween class or the
onMotionFinished
event handler to create a unique effect.
You combine the TransitionManager and Tween classes to animate a dynamically loaded
movie clip and fade it in on the Stage after it fully loads from the remote server, as the
following procedure shows.
To use the TransitionManager and Tween classes together:
1.
Create a new Flash document and save the file as
combination.fla
.
2.
Add the following ActionScript on Frame 1 of the Timeline:
import mx.transitions.*;
import mx.transitions.easing.*;
var mcl_obj:Object = new Object();
mcl_obj.onLoadInit = function(target_mc:MovieClip) {
new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true);
TransitionManager.start(target_mc, {type:Fly,
direction:Transition.IN, duration:3, easing:Elastic.easeInOut,
startPoint:6});
};
var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.addListener(mcl_obj);
my_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg",
this.createEmptyMovieClip("img_mc", this.getNextHighestDepth()));
This code is separated into three main sections.
The first section of code imports the classes within the transitions package as well as the
transitions.easing
package. You import the entire transitions package in this example
so you do not need to enter the fully qualified class name for the Tween class,
TransitionManager class, or the selected transition (in this case,
Fly
). This process can
reduce the amount of code you type and save you from potential typographical errors.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...