532
Animation, Filters, and Drawings
Moving the mouse pointer along the
x
-axis modifies the blur filter’s
blurX
property.
Moving the mouse pointer along the
y
-axis modifies the blur filter’s
blurY
property. The
closer the mouse pointer is to the upper-left corner of the Stage, the less blurring is applied
to the movie clip.
Animating a filter by using ActionScript
You can use ActionScript, such as the Tween class, to animate filters at runtime, which lets
you apply interesting, animated effects to your Flash applications.
In the following example, you see how to combine the BlurFilter with the Tween class to
create an animated blur that modifies the Blur filter between a value of 0 and 10 at runtime.
To animate blurs using the Tween class:
1.
Create a new Flash document and save it as
animatedfilter.fla
.
2.
Add the following ActionScript to Frame 1 of the Timeline:
import flash.filters.BlurFilter;
import mx.transitions.Tween;
import mx.transitions.easing.*;
this.createEmptyMovieClip("holder_mc", 10);
holder_mc.createEmptyMovieClip("img_mc", 20);
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc._x = (Stage.width - target_mc._width) / 2;
target_mc._y = (Stage.height - target_mc._height) / 2;
var myTween:Tween = new Tween(target_mc, "blur", Strong.easeInOut, 0,
20, 3, true);
myTween.onMotionChanged = function() {
target_mc._parent.filters = [new BlurFilter(target_mc.blur,
target_mc.blur, 1)];
};
myTween.onMotionFinished = function() {
myTween.yoyo();
}
};
var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.addListener(mclListener);
my_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg",
holder_mc.img_mc);
Содержание 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...