EasyManua.ls Logo

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

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...
Working with filters using ActionScript 521
The last four colors range from 129 through 255, increasing in value so each value is
greater than or equal to the previous one. This is the second bevel edge, for example,
your shadow.
If you think of a gradient as composed of stripes of various colors, blending into each other,
each ratio value sets the number of pixels for the associated color, thus setting the width of the
color stripe in the gradient. If you want an equal distribution of colors for each edge:
Use an odd number of colors, where the middle color is the base fill.
Distribute the values between 0 through 127 and 129 through 255 equally among
your colors.
Adjust the value to change the width of each stripe of color in the gradient.
The angle value determines the angle at which the gradient colors are applied to the object;
meaning, where the highlight and shadow appear on the object. The colors are applied in the
same order as the array.
The following code takes a pink square (drawn with the Drawing API) and applies a rainbow
gradient filter. The colors, in the order in which they are present in the array, are: blue, green,
purple, and yellow (highlight); red (base fill); yellow, purple, green, black (shadow). To
determine the ratios values, we assign four highlight colors values from 0 to 127, making
them roughly equal, and shadow colors from 129 to 255. The colors on the outer edges, blue
(16) and black (235).
var colors:Array = [0x0000FF, 0x00FF00, 0x9900FF, 0xFFFF00, 0xFF0000,
0xFFFF00, 0x9900FF, 0x00FF00,0x000000];
var alphas:Array = [1, 1, 1, 1, 1, 1, 1, 1, 1];
var ratios:Array = [16, 32, 64, 96, 128, 160, 192, 224, 235];
var gradientBevel:GradientBevelFilter = new GradientBevelFilter(8, 225,
colors, alphas, ratios, 16, 16, 1.3, 2, "inner", false);
NOTE
The angle value determines which edge is the highlight and which edge is the
shadow.

Table of Contents

Related product manuals