518
Animation, Filters, and Drawings
To use the bevel filter:
1.
Create a new Flash document and save it as
bevel.fla
.
2.
Add the following ActionScript to Frame 1 of the Timeline:
import flash.filters.BevelFilter;
// define a bevel filter
var bevel:BevelFilter = new BevelFilter(4, 45, 0xFFFFFF, 1, 0xCC0000, 1,
10, 10, 2, 3);
// create a new shapeClip instance
var shapeClip:MovieClip = this.createEmptyMovieClip("shapeClip", 1);
// use the 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 on the Stage
shapeClip._x = 100;
shapeClip._y = 100;
// click the mouse to increase the strength
shapeClip.onPress = function():Void {
bevel.st= 2;
shapeClip.filters = [bevel];
};
// define a listener to modify the filter when pointer moves
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function():Void {
bevel.distance = (_xmouse / Stage.width) * 10;
bevel.blurX = (_ymouse / Stage.height) * 10;
bevel.blurY = bevel.blurX;
shapeClip.filters = [bevel];
};
Mouse.addListener(mouseListener);
The first section of code defines a BevelFilter instance, and uses the Drawing API to draw
a square on the Stage. When you click the square on the Stage, the current strength value
of the bevel increments and gives the bevel a taller, sharper appearance. The second
section of code defines a mouse listener, which modifies the bevel’s distance and blurring
based on the current position of the mouse pointer.
Содержание 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...