Packagecom.afcomponents.umap.styles
Classpublic class GradientStyle
InheritanceGradientStyle Inheritance Style

Specifies a gradient fill. This style used by a GeometryStyle class in the GeometryStyle.fillGradient and GeometryStyle.strokeGradient properties.


Example
Here is quick example that shows the usage of GradientStyle & GeometryStyle classes for creating a gradient-filled rectangle:
 import com.afcomponents.umap.styles.GeometryStyle;
 import com.afcomponents.umap.styles.GradientStyle;
 import flash.geom.Matrix;
 import flash.display.GradientType;
 import flash.display.SpreadMethod;
  
 // create new geometry style & define gradient fill style
 var style:GeometryStyle = new GeometryStyle();
 style.stroke = GeometryStyle.NONE;
 style.fill = GeometryStyle.GRADIENT;
 style.fillGradient = new GradientStyle();
 with (style.fillGradient)
 {
  type = GradientType.LINEAR;
  colors = [0xFFCC00, 0x000000];
  alphas = [100, 100];
  ratios = [0x00, 0xFF];
  matrix = new Matrix();
  matrix.createGradientBox(20, 20, 0, 0, 0);
  spreadMethod = SpreadMethod.REFLECT;
 }
  
 // apply geometry style to draw gradient-filled rectangle
 style.applyTo(this.graphics);
 this.graphics.drawRect(0,0,100,100);

You should see a gradient-filled rectangle after executing the code:

GradientStyle example

See also

GeometryStyle
GeometryStyle.fillGradient
GeometryStyle.strokeGradient
flash.display.Graphics


Public Properties
 PropertyDefined by
  alphas : Array = null
An array of alpha values for the corresponding colors in the colors array.
GradientStyle
  colors : Array = null
An array of RGB hexadecimal color values to be used in the gradient.
GradientStyle
  focalPointRatio : Number = 0
A number that controls the location of the focal point of the gradient.
GradientStyle
  interpolationMethod : String = "rgb"
A value from the InterpolationMethod class that specifies which value to use.
GradientStyle
  matrix : Matrix = null
A transformation matrix as defined by the flash.geom.Matrix class.
GradientStyle
  ratios : Array = null
An array of color distribution ratios.
GradientStyle
  spreadMethod : String = "pad"
A value from the SpreadMethod class that specifies which spread method to use.
GradientStyle
  type : String = "null"
A value from the GradientType class that specifies which gradient type to use.
GradientStyle
Public Methods
 MethodDefined by
  
GradientStyle(param:Object = null)
GradientStyle contructor.
GradientStyle
 Inherited
Creates a copy of the Style object.
Style
 Inherited
concat(param:Object):Style
Creates a clone of this Style, copies the properties from specified object and returns the new style.
Style
 Inherited
copy(object:Object):void
Copies all the properties from the specified object into the Style object.
Style
 Inherited
copyStyle(dest:Object, src:Object):void
[static] Copies all properties of one object into another.
Style
 Inherited
[static] Returns new Style object, from the source XML object.
Style
 Inherited
getXMLFromStyle(style:Style, name:String = ""):XML
[static] Returns an XML object that represents all the style's properties.
Style
 Inherited
toString():String
Returns a String that represents all the style's properties.
Style
 Inherited
toXML(afcTags:Boolean = false):XML
Abstract function.
Style
Property detail
alphasproperty
public var alphas:Array = 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.

The default value is null.

colorsproperty 
public var colors:Array = 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.

The default value is null.

focalPointRatioproperty 
public var focalPointRatio:Number = 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.

The default value is 0.

interpolationMethodproperty 
public var interpolationMethod:String = "rgb"

A value from the InterpolationMethod class that specifies which value to use. Possible values are InterpolationMethod.linearRGB and InterpolationMethod.RGB.

The default value is InterpolationMethod.RGB.

matrixproperty 
public var matrix:Matrix = 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.

The default value is null.

See also

flash.geom.Matrix
ratiosproperty 
public var ratios:Array = 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.

The default value is null.

spreadMethodproperty 
public var spreadMethod:String = "pad"

A value from the SpreadMethod class that specifies which spread method to use. Possible values include: SpreadMethod.PAD, SpreadMethod.REFLECT, and SpreadMethod.REPEAT

The default value is SpreadMethod.PAD.

typeproperty 
public var type:String = "null"

A value from the GradientType class that specifies which gradient type to use. Possible values are GradientType.LINEAR and GradientType.RADIAL.

The default value is null.

Constructor detail
GradientStyle()constructor
public function GradientStyle(param:Object = null)

GradientStyle contructor.

Creates new GradientStyle object with the default parameters. Properties defined in param object will override the default values.

Parameters
param:Object (default = null) — Object that holds all the properites of a style you wish to override upon its creation.