| Package | com.afcomponents.umap.styles |
| Class | public class GeometryStyle |
| Inheritance | GeometryStyle Style |
| Subclasses | BaloonStyle, ComponentStyle, InfoWindowStyle, MarkerStyle |
applyTo() method to set the drawing style for the specified Graphics object.
import com.afcomponents.umap.styles.GeometryStyle;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display.StageQuality;
// create new timer object to draw new rect each 50 miliseconds, maximum 100 rectangles
var timer:Timer = new Timer(50, 100);
timer.addEventListener(TimerEvent.TIMER, drawNextRect);
timer.start();
// setup stage appearence
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.quality = StageQuality.LOW;
// draw 1 rect now
drawNextRect();
// draw random rectangle with random style
function drawNextRect(event:TimerEvent = null)
{
// define random style
var style:GeometryStyle = new GeometryStyle();
style.fillRGB = uint(Math.random() * 0xFFFFFF);
style.fillAlpha = Math.random() * 0.5 + 0.5;
style.strokeRGB = uint(Math.random() * 0xFFFFFF);
style.strokeAlpha = Math.random() * 0.5 + 0.5;
// apply the style & draw random rectangle
style.applyTo(this.graphics);
var px:Number = Math.random() * stage.stageWidth - stage.stageWidth / 10;
var py:Number = Math.random() * stage.stageHeight - stage.stageHeight / 10;
var w:Number = Math.random() * stage.stageWidth / 2 + stage.stageWidth / 10;
var h:Number = Math.random() * stage.stageHeight / 2 + stage.stageHeight / 10;
this.graphics.drawRect(px, py, w, h);
} You should see the stage quickly fill up with random rectangles after executing the code:
See also
| Property | Defined by | ||
|---|---|---|---|
| fill : String = "rgb"
Specify a fill style to use when drawing on a Graphics object.
| GeometryStyle | ||
| fillAlpha : Number = 0.5
Defines fill color opacity.
| GeometryStyle | ||
| fillBitmap : BitmapStyle = null
Defines fill bitmap properties as a
BitmapStyle object. | GeometryStyle | ||
| fillGradient : GradientStyle = null
Defines fill gradient properties as a
GradientStyle object. | GeometryStyle | ||
| fillRGB : uint = 0x89B9FE
Defines RGB fill color.
| GeometryStyle | ||
| stroke : String = "rgb"
Specify a stroke style to use when drawing on a Graphics object.
| GeometryStyle | ||
| strokeAlpha : Number = 1.0
Defines stroke opacity.
| GeometryStyle | ||
| strokeGradient : GradientStyle = null
Defines stroke gradient properties as a
GradientStyle object. | GeometryStyle | ||
| strokeRGB : uint = 0x000000
Defines RGB stroke color.
| GeometryStyle | ||
| strokeStyle : StrokeStyle
Defines advanced stroke properties as a
StrokeStyle object. | GeometryStyle | ||
| strokeThickness : Number = 2.0
An integer that indicates the thickness of the line in points.
| GeometryStyle | ||
| Method | Defined by | ||
|---|---|---|---|
|
GeometryStyle(param:Object = null)
GeometryStyle contructor.
| GeometryStyle | ||
|
applyTo(graphics:Graphics, noFill:Boolean = false, noStroke:Boolean = false):void
Applies current fill & stroke style to the specified
Graphics object. | GeometryStyle | ||
![]() |
Creates a copy of the
Style object. | Style | |
![]() |
Creates a clone of this
Style,
copies the properties from specified object and returns the new style. | Style | |
![]() |
copy(object:Object):void
Copies all the properties from the specified object into the
Style object. | Style | |
![]() |
copyStyle(dest:Object, src:Object):void
[static]
Copies all properties of one object into another.
| Style | |
|
fromXML(xml:XML):GeometryStyle
[static]
Creates new GeometryStyle from XML object in KML 2.1 format.
| GeometryStyle | ||
![]() |
getStyleFromXML(xml:XML):Style
[static]
Returns new
Style object, from the source XML object. | Style | |
![]() |
getXMLFromStyle(style:Style, name:String = ""):XML
[static]
Returns an
XML object that represents all the style's properties. | Style | |
![]() |
toString():String
Returns a
String that represents all the style's properties. | Style | |
|
toXML(afcTags:Boolean = false):XML
Builds an XML object in KML 2.1 format that describes the GeometryStyle.
| GeometryStyle | ||
| Constant | Defined by | ||
|---|---|---|---|
| BITMAP : String = "bitmap" [static]
The
GeometryStyle.BITMAP constant defines the value of the fill
property of the GeometryStyle object that indicates that bitmap fill should be used. | GeometryStyle | ||
| GRADIENT : String = "gradient" [static]
The
GeometryStyle.GRADIENT constant defines the value of the fill or stroke
property of the GeometryStyle object that indicates that gradient fill or stroke should be used. | GeometryStyle | ||
| NONE : String = "none" [static]
The
GeometryStyle.NONE constant defines the value of the fill or stroke
property of the GeometryStyle object that indicates that no fill or stroke should be used. | GeometryStyle | ||
| RGB : String = "rgb" [static]
The
GeometryStyle.RGB constant defines the value of the fill or stroke
property of the GeometryStyle object that indicates that simple one-color fill or stroke should be used. | GeometryStyle | ||
| fill | property |
public var fill:String = "rgb"Specify a fill style to use when drawing on a Graphics object.
This property can be one of the following:
GeometryStyle.NONE - don't use fill. GeometryStyle.RGB - use simple one-color fill.
The color value will be taken from fillRGB property and the opactity will be taken from fillAlpha property.
For example, here is how you can draw a simple orange box:
![]() |
var style:GeometryStyle = new GeometryStyle(); style.fillRGB = 0xFFCC00; style.applyTo(this.graphics); this.graphics.drawRect(0, 0, 50, 50); |
GeometryStyle.GRADIENT - use gradient fill. You should define fillGradient property as a new GradientStyle object
before using applyTo() method with this fill mode or RGB fill will be used.
For example, here is how you can draw a gradient-filled box:
![]() |
var style:GeometryStyle = new GeometryStyle();
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;
}
style.applyTo(this.graphics);
this.graphics.drawRect(0, 0, 50, 50); |
GeometryStyle.BITMAP - use bitmap fill. You should define fillBitmap property as a new BitmapStyle object
before using applyTo() method with this fill mode or RGB fill will be used.
For example, here is how you can draw a bitmap-filled box:
![]() |
// create checkered pattern
var pattern:Sprite = new Sprite();
with(pattern.graphics)
{
beginFill(0xFFCC00);
drawRect(0, 0, 10, 10);
drawRect(10, 10, 10, 10);
beginFill(0x000000);
drawRect(0, 10, 10, 10);
drawRect(10, 0, 10, 10);
}
// create new bitmap from checkered pattern
var bitmap:BitmapData = new BitmapData(pattern.width, pattern.height);
bitmap.draw(pattern);
// create new GeometryStyle with bitmap fill
var style:GeometryStyle = new GeometryStyle();
style.fillBitmap = new BitmapStyle();
style.fill = GeometryStyle.BITMAP;
style.fillBitmap.bitmap = bitmap;
// apply geometry style to draw bitmap-filled rectangle
style.applyTo(this.graphics);
this.graphics.drawRect(0, 0, 50, 50); |
The default value is GeometryStyle.RGB.
See also
| fillAlpha | property |
public var fillAlpha:Number = 0.5
Defines fill color opacity. Used if fill property is set to GeometryStyle.RGB.
The default value is 0.5 (50% opacity).
| fillBitmap | property |
public var fillBitmap:BitmapStyle = null
Defines fill bitmap properties as a BitmapStyle object.
Used if fill property is set to GeometryStyle.BITMAP.
Please see BitmapStyle class for more information.
The default value is null.
See also
| fillGradient | property |
public var fillGradient:GradientStyle = null
Defines fill gradient properties as a GradientStyle object.
Used if fill property is set to GeometryStyle.GRADIENT.
Please see GradientStyle class for more information.
The default value is null.
See also
| fillRGB | property |
public var fillRGB:uint = 0x89B9FE
Defines RGB fill color. Used if fill property is set to GeometryStyle.RGB.
The default value is 0x89B9FE (light-blue);.
| stroke | property |
public var stroke:String = "rgb"Specify a stroke style to use when drawing on a Graphics object.
This property can be one of the following:
GeometryStyle.NONE - don't use stroke. Stroke style is set to transparent.GeometryStyle.RGB - use simple one-color stroke.
The color value will be taken from strokeRGB property and the opactity will be taken from strokeAlpha property.
For example, here is how you can draw a simple orange line:
![]() |
var style:GeometryStyle = new GeometryStyle(); style.strokeRGB = 0xFFCC00; style.strokeAlpha = 0.8; style.strokeThickness = 10; style.applyTo(this.graphics); this.graphics.moveTo(50, 0); this.graphics.lineTo(0, 50); |
GeometryStyle.GRADIENT - use gradient stroke. You should define strokeGradient property as a new GradientStyle object
before using applyTo() method with this stroke mode or RGB stroke will be used.
![]() |
var style:GeometryStyle = new GeometryStyle();
style.strokeThickness = 10;
style.stroke = GeometryStyle.GRADIENT;
style.strokeGradient = new GradientStyle();
with (style.strokeGradient)
{
type = GradientType.LINEAR;
colors = [0xFFCC00, 0x000000];
alphas = [100, 100];
ratios = [0x00, 0xFF];
matrix = new Matrix();
matrix.createGradientBox(50, 50, 0, 0, 0);
matrix.rotate(-45 Math.PI / 180);
spreadMethod = SpreadMethod.REFLECT;
}
style.applyTo(this.graphics);
this.graphics.moveTo(50, 0);
this.graphics.lineTo(0, 50); |
The default value is GeometryStyle.RGB.
See also
| strokeAlpha | property |
public var strokeAlpha:Number = 1.0
Defines stroke opacity. Used if stroke property is set to GeometryStyle.RGB.
The default value is 1.0 (100% opacity).
| strokeGradient | property |
public var strokeGradient:GradientStyle = null
Defines stroke gradient properties as a GradientStyle object.
Used if stroke property is set to GeometryStyle.GRADIENT.
Please see GradientStyle class for more information.
The default value is null.
See also
| strokeRGB | property |
public var strokeRGB:uint = 0x000000
Defines RGB stroke color. Used if stroke property is set to GeometryStyle.RGB.
The default value is 0x000000 (black).
| strokeStyle | property |
public var strokeStyle:StrokeStyle
Defines advanced stroke properties as a StrokeStyle object.
This object is defined by default, and should be never set to null.
Please StrokeStyle class for more information.
See also
| strokeThickness | property |
public var strokeThickness:Number = 2.0An integer that indicates the thickness of the line in points. Valid values are 0 to 255.
If a number is not specified, or if the parameter is Number.NaN, a line is not drawn.
If a value of less than 0 is passed, the default is 0.
The value 0 indicates hairline thickness; the maximum thickness is 255.
If a value greater than 255 is passed, the default is 255.
The default value is 2.
| GeometryStyle | () | constructor |
public function GeometryStyle(param:Object = null)GeometryStyle contructor.
Creates new GeometryStyle object with the default parameters.
Properties defined in param object will override the default values.
Please use applyTo() method to set the drawing style for the specified Graphics object.
param:Object (default = null) — Object that holds all the properites of a style you wish to override upon its creation.
|
See also
| applyTo | () | method |
public function applyTo(graphics:Graphics, noFill:Boolean = false, noStroke:Boolean = false):void
Applies current fill & stroke style to the specified Graphics object.
You should manually call clear() method if you wish to clear the canvas.
Additionally you can override fill or stroke usage by specifying noFill or noStroke parameter.
The methods will fail if you attempt to pass an invalid graphics object.
graphics:Graphics — Reference to a Graphics object to apply the drawing style to.
|
|
noFill:Boolean (default = false) — Value of true overrides applying of the fill style.
|
|
noStroke:Boolean (default = false) — Value of true forces invisible stroke usage.
|
— Invalid graphics object.
|
See also
| fromXML | () | method |
public static function fromXML(xml:XML):GeometryStyleCreates new GeometryStyle from XML object in KML 2.1 format.
Parametersxml:XML — XML object with root <Style> node.
|
GeometryStyle —
New GeometryStyle object, or null if an error occured
|
<Style id="ID">
<LineStyle id="ID">
<!-- inherited from ColorStyle -->
<color>ffffffff</color> <!-- kml:color -->
<colorMode>normal</colorMode> <!-- colorModeEnum: normal or random -->
<!-- specific to LineStyle -->
<width>1</width> <!-- float -->
</LineStyle>
<PolyStyle id="ID">
<!-- inherited from ColorStyle -->
<color>ffffffff</color> <!-- kml:color -->
<colorMode>normal</colorMode> <!-- kml:colorModeEnum: normal or random -->
<!-- specific to PolyStyle -->
<fill>1</fill> <!-- boolean -->
<outline>1</outline> <!-- boolean -->
</PolyStyle>
</Style>| toXML | () | method |
public override function toXML(afcTags:Boolean = false):XMLBuilds an XML object in KML 2.1 format that describes the GeometryStyle.
ParametersafcTags:Boolean (default = false) — Flag that determines whether to generate KML data with extended AFC tags.
|
XML — XML object in KML 2.1 format.
|
| BITMAP | constant |
public static const BITMAP:String = "bitmap"
The GeometryStyle.BITMAP constant defines the value of the fill
property of the GeometryStyle object that indicates that bitmap fill should be used.
| GRADIENT | constant |
public static const GRADIENT:String = "gradient"
The GeometryStyle.GRADIENT constant defines the value of the fill or stroke
property of the GeometryStyle object that indicates that gradient fill or stroke should be used.
| NONE | constant |
public static const NONE:String = "none"
The GeometryStyle.NONE constant defines the value of the fill or stroke
property of the GeometryStyle object that indicates that no fill or stroke should be used.
| RGB | constant |
public static const RGB:String = "rgb"
The GeometryStyle.RGB constant defines the value of the fill or stroke
property of the GeometryStyle object that indicates that simple one-color fill or stroke should be used.