
MovieClip.beginGradientFill() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
642
|
ActionScript Language Reference
// Make the movie clip.
this.createEmptyMovieClip("drawing_mc", 1);
// Draw the gradient-filled square.
drawing_mc.moveTo(25, 0);
drawing_mc.beginGradientFill(fillType, colors, alphas, ratios, matrix);
drawing_mc.lineTo(125, 0);
drawing_mc.lineTo(125, 100);
drawing_mc.lineTo(25, 100);
drawing_mc.lineTo(25, 0);
drawing_mc.endFill();
By combining matrices, we can use a single matrix to describe scale, rotation, and transla-
tion together. Matrix multiplication is outside the scope of this discussion; however,
Macromedia provides a TransformMatrix class on the Flash MX CD under: Goodies\
Macromedia\Other Samples\transformmatrix.as. It defines easy-to-use methods for speci-
fying and combining transformation matrices.
Usage
Even though Flash attempts to fix improperly specified shapes (e.g., a shape with no
endFill() method), predictable results can be guaranteed only when the shape-drawing rules
described under MovieClip.beginFill() are observed.
Example
The following code draws a triangle with a red, green, and blue radial gradient. The
triangle is centered about the clip’s registration point, and the gradient is centered within
the triangle:
// Create an empty clip for drawing, and set the pen position
this.createEmptyMovieClip("drawing_mc", ...