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);
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...