EasyManua.ls Logo

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

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...
532 Animation, Filters, and Drawings
Moving the mouse pointer along the x-axis modifies the blur filters 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);

Table of Contents

Related product manuals