MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 547

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Using complex gradient fills
The Flash Drawing API supports gradient fills as well as solid fills. The following procedure
creates a new movie clip on the Stage, use the Drawing API to create a square, and then fills
the square with a radial red and blue gradient.
To create a complex gradient:
1.
Create a new Flash document and save it as radialgradient.fla.
2.
Add the following ActionScript to Frame 1 of the Timeline:
this.createEmptyMovieClip("gradient_mc", 10);
var fillType:String = "radial";
var colors:Array = [0xFF0000, 0x0000FF];
var alphas:Array = [100, 100];
var ratios:Array = [0, 0xFF];
var matrix:Object = {a:200, b:0, c:0, d:0, e:200, f:0, g:200, h:200,
i:1};
var spreadMethod:String = "reflect";
var interpolationMethod:String = "linearRGB";
var focalPointRatio:Number = 0.9;
with (gradient_mc) {
beginGradientFill(fillType, colors, alphas, ratios, matrix,
spreadMethod, interpolationMethod, focalPointRatio);
moveTo(100, 100);
lineTo(100, 300);
lineTo(300, 300);
lineTo(300, 100);
lineTo(100, 100);
endFill();
}
The preceding ActionScript code uses the Drawing API to create a square on the Stage
and calls the beginGradientFill() method to fill the square with a red and blue
circular gradient.
3.
Save the Flash document and select Control > Test Movie to view the Flash file.
Drawing with ActionScript
547

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents