EasyManua.ls Logo

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

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...
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.strength += 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 bevels distance and blurring
based on the current position of the mouse pointer.

Table of Contents

Related product manuals