| Package | flash.display |
| Class | public final class GraphicsGradientFill |
| Inheritance | GraphicsGradientFill Object |
| Implements | IGraphicsFill, IGraphicsData |
A GraphicsGradientFill object can be used with the Graphics.drawGraphicsData() method.
when this object is drawn it is the equivalent of calling the Graphics.beginGradientFill() method.
See also
| Property | Defined By | ||
|---|---|---|---|
| alphas : Array
An array of alpha values for the corresponding colors in the colors array;
valid values are 0 to 1. | GraphicsGradientFill | ||
| colors : Array
An array of RGB hexadecimal color values to be used in the gradient; for example,
red is 0xFF0000, blue is 0x0000FF, and so on. | GraphicsGradientFill | ||
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | |
| focalPointRatio : Number
A number that controls the
location of the focal point of the gradient. | GraphicsGradientFill | ||
| interpolationMethod : String
A value from the InterpolationMethod class that
specifies which value to use: InterpolationMethod.LINEAR_RGB or
InterpolationMethod.RGB
For example, consider a simple linear gradient between two colors (with the spreadMethod
parameter set to SpreadMethod.REFLECT). | GraphicsGradientFill | ||
| matrix : Matrix
A transformation matrix as defined by the
flash.geom.Matrix class. | GraphicsGradientFill | ||
![]() | prototype : Object [static]
A reference to the prototype object of a class or function object. | Object | |
| ratios : Array
An array of color distribution ratios; valid values are 0 to 255. | GraphicsGradientFill | ||
| spreadMethod : String
A value from the SpreadMethod class that
specifies which spread method to use, either: SpreadMethod.PAD,
SpreadMethod.REFLECT, or SpreadMethod.REPEAT. | GraphicsGradientFill | ||
| type : String
A value from the GradientType class that
specifies which gradient type to use: GradientType.LINEAR or
GradientType.RADIAL. | GraphicsGradientFill | ||
| Method | Defined By | ||
|---|---|---|---|
GraphicsGradientFill(type:String = "linear", colors:Array = null, alphas:Array = null, ratios:Array = null, matrix:* = null, spreadMethod:* = pad, interpolationMethod:String = "rgb", focalPointRatio:Number = 0.0)
Creates a new GraphicsGradientFill object. | GraphicsGradientFill | ||
![]() |
Indicates whether an object has a specified property defined. | Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | |
![]() |
Indicates whether the specified property exists and is enumerable. | Object | |
![]() |
Sets the availability of a dynamic property for loop operations. | Object | |
![]() |
Returns the string representation of the specified object. | Object | |
![]() |
Returns the primitive value of the specified object. | Object | |
| alphas | property |
public var alphas:ArrayAn array of alpha values for the corresponding colors in the colors array; valid values are 0 to 1. If the value is less than 0, the default is 0. If the value is greater than 1, the default is 1.
| colors | property |
public var colors:ArrayAn array of RGB hexadecimal color values to be used in the gradient; for example, red is 0xFF0000, blue is 0x0000FF, and so on. You can specify up to 15 colors. For each color, be sure you specify a corresponding value in the alphas and ratios parameters.
| focalPointRatio | property |
public var focalPointRatio:Number
A number that controls the
location of the focal point of the gradient. 0 means that the focal point is in the center. 1
means that the focal point is at one border of the gradient circle. -1 means that the focal point
is at the other border of the gradient circle. A value less than -1 or greater than
1 is rounded to -1 or 1. For example, the following example
shows a focalPointRatio set to 0.75:
| interpolationMethod | property |
public var interpolationMethod:String
A value from the InterpolationMethod class that
specifies which value to use: InterpolationMethod.LINEAR_RGB or
InterpolationMethod.RGB
For example, consider a simple linear gradient between two colors (with the spreadMethod
parameter set to SpreadMethod.REFLECT). The different interpolation methods affect
the appearance as follows:
| |
InterpolationMethod.LINEAR_RGB | InterpolationMethod.RGB |
See also
| matrix | property |
public var matrix:Matrix
A transformation matrix as defined by the
flash.geom.Matrix class. The flash.geom.Matrix class includes a
createGradientBox() method, which lets you conveniently set up
the matrix for use with the beginGradientFill() method.
See also
| ratios | property |
public var ratios:ArrayAn array of color distribution ratios; valid values are 0 to 255. This value defines the percentage of the width where the color is sampled at 100%. The value 0 represents the left-hand position in the gradient box, and 255 represents the right-hand position in the gradient box.
Note: This value represents positions in the gradient box, not the
coordinate space of the final gradient, which might be wider or thinner than the gradient box.
Specify a value for each value in the colors parameter.
For example, for a linear gradient that includes two colors, blue and green, the
following example illustrates the placement of the colors in the gradient based on different values
in the ratios array:
ratios | Gradient |
|---|---|
[0, 127] | ![]() |
[0, 255] | ![]() |
[127, 255] | ![]() |
The values in the array must increase sequentially; for example,
[0, 63, 127, 190, 255].
| spreadMethod | property |
public var spreadMethod:String
A value from the SpreadMethod class that
specifies which spread method to use, either: SpreadMethod.PAD,
SpreadMethod.REFLECT, or SpreadMethod.REPEAT.
For example, consider a simple linear gradient between two colors:
import flash.geom.*
import flash.display.*
var fillType:String = GradientType.LINEAR;
var colors:Array = [0xFF0000, 0x0000FF];
var alphas:Array = [1, 1];
var ratios:Array = [0x00, 0xFF];
var matr:Matrix = new Matrix();
matr.createGradientBox(20, 20, 0, 0, 0);
var spreadMethod:String = SpreadMethod.PAD;
this.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);
this.graphics.drawRect(0,0,100,100);
This example uses SpreadMethod.PAD for the spread method, and
the gradient fill looks like the following:

If you use SpreadMethod.REFLECT for the spread method, the gradient fill
looks like the following:

If you use SpreadMethod.REPEAT for the spread method, the gradient fill
looks like the following:

See also
| type | property |
public var type:String
A value from the GradientType class that
specifies which gradient type to use: GradientType.LINEAR or
GradientType.RADIAL.
See also
| GraphicsGradientFill | () | Constructor |
public function GraphicsGradientFill(type:String = "linear", colors:Array = null, alphas:Array = null, ratios:Array = null, matrix:* = null, spreadMethod:* = pad, interpolationMethod:String = "rgb", focalPointRatio:Number = 0.0)Creates a new GraphicsGradientFill object.
Parameterstype:String (default = "linear") — A value from the GradientType class that
specifies which gradient type to use: GradientType.LINEAR or
GradientType.RADIAL.
| |
colors:Array (default = null) — An array of RGB hexadecimal color values to be used in the gradient; for example,
red is 0xFF0000, blue is 0x0000FF, and so on. You can specify up to 15 colors.
For each color, be sure you specify a corresponding value in the alphas and ratios parameters.
| |
alphas:Array (default = null) — An array of alpha values for the corresponding colors in the colors array;
valid values are 0 to 1. If the value is less than 0, the default is 0. If the value is
greater than 1, the default is 1.
| |
ratios:Array (default = null) — An array of color distribution ratios; valid values are 0 to 255. This value
defines the percentage of the width where the color is sampled at 100%. The value 0 represents
the left-hand position in the gradient box, and 255 represents the right-hand position in the
gradient box.
| |
matrix:* (default = null) — A transformation matrix as defined by the
flash.geom.Matrix class. The flash.geom.Matrix class includes a
createGradientBox() method, which lets you conveniently set up
the matrix for use with the beginGradientFill() method.
| |
spreadMethod:* (default = pad) — A value from the SpreadMethod class that
specifies which spread method to use, either: SpreadMethod.PAD,
SpreadMethod.REFLECT, or SpreadMethod.REPEAT.
| |
interpolationMethod:String (default = "rgb") — A value from the InterpolationMethod class that
specifies which value to use: InterpolationMethod.LINEAR_RGB or
InterpolationMethod.RGB
| |
focalPointRatio:Number (default = 0.0) — A number that controls the
location of the focal point of the gradient. 0 means that the focal point is in the center. 1
means that the focal point is at one border of the gradient circle. -1 means that the focal point
is at the other border of the gradient circle. A value less than -1 or greater than
1 is rounded to -1 or 1.
|
See also