516
Animation, Filters, and Drawings
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.s+;
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
onMouseDown
, which causes the strength of the gradient glow to
increase. The second event handler is
onMouseMove
, which is called whenever the mouse
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.
Содержание 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...