MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 514

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

The following procedure demonstrates how you can apply a glow filter to a dynamically
created movie clip on the Stage. Moving your mouse pointer around the Stage causes the
movie clip's blur to change, and clicking the dynamically created shape causes the filter's
strength to increase.
To use the glow filter:
1.
Create a new Flash document and save it as glowfilter.fla.
2.
Add the following ActionScript code to Frame 1 of the Timeline:
import flash.filters.GlowFilter;
this.createEmptyMovieClip("shapeClip", 10);
with (shapeClip) {
beginFill(0xFF0000, 100);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 100);
lineTo(0, 100);
lineTo(0, 0);
endFill();
}
shapeClip._x = 100;
shapeClip._y = 100;
shapeClip.onPress = function():Void {
glow.strength++;
shapeClip.filters = [glow];
};
var glow:GlowFilter = new GlowFilter(0xCC0000, 0.5, 10, 10, 2, 3);
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function():Void {
glow.blurX = (_xmouse / Stage.width) * 255;
glow.blurY = (_ymouse / Stage.width) * 255;
shapeClip.filters = [glow];
};
Mouse.addListener(mouseListener);
This code uses the Drawing API to draw a square on the Stage, and applies a glow filter to
the shape. Whenever the mouse pointer moves along the x-axis or y-axis, the glow filter's
blur is calculated and applied to the shape.
514
Animation, Filters, and Drawings

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

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?

This manual is also suitable for:

Flash 8

Table of Contents