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

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

To apply a gradient glow filter:
1.
Create a new Flash document and save it as gradientglow.fla.
2.
Add the following ActionScript to Frame 1 of the Timeline:
import flash.filters.GradientGlowFilter;
// create a new shapeClip instance
var shapeClip:MovieClip = this.createEmptyMovieClip("shapeClip", 10);
// use Drawing API to create a shape
with (shapeClip) {
beginFill(0xFF0000, 100);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 100);
lineTo(0, 100);
lineTo(0, 0);
endFill();
}
// position the shape
shapeClip._x = 100;
shapeClip._y = 100;
// define a gradient glow
var gradientGlow:GradientGlowFilter = new GradientGlowFilter(0, 45,
[0x000000, 0xFF0000], [0, 1], [0, 255], 10, 10, 2, 3, "outer");
// define a mouse listener, listen for two events
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function():Void {
gradientGlow.strength++;
shapeClip.filters = [gradientGlow];
};
mouseListener.onMouseMove = function():Void {
gradientGlow.blurX = (_xmouse / Stage.width) * 255;
gradientGlow.blurY = (_ymouse / Stage.height) * 255;
shapeClip.filters = [gradientGlow];
};
Mouse.addListener(mouseListener);
The previous code is split into three sections. The first section of code uses the Drawing
API to create a square and positions the shape on the Stage. The second section of code
defines a new gradient glow filter instance, which creates a glow from red to black. The
third section of code defines a mouse listener, which listens for two mouse event handlers.
The first event handler is
increase. The second event handler is
pointer moves within the SWF file. The further the mouse pointer moves from the upper-
left corner of the Flash document, the stronger the glow effect that is applied.
516
Animation, Filters, and Drawings
, which causes the strength of the gradient glow to
onMouseDown
onMouseMove
, which is called whenever the mouse

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