| Package | com.afcomponents.umap.styles |
| Class | public class StrokeStyle |
| Inheritance | StrokeStyle Style |
GeometryStyle class
in the GeometryStyle.strokeStyle property.
StrokeStyle & GeometryStyle classes
for drawing a polyline with an advanced stroke style pen:
import com.afcomponents.umap.styles.GeometryStyle;
import com.afcomponents.umap.styles.StrokeStyle;
import flash.display.JointStyle;
import flash.display.CapsStyle;
// create new GeometryStyle & define new StrokeStyle
var style:GeometryStyle = new GeometryStyle();
style.fill = GeometryStyle.NONE;
style.strokeThickness = 15;
style.strokeRGB = 0xFFCC00;
style.strokeAlpha = 0.8;
style.strokeStyle = new StrokeStyle();
style.strokeStyle.jointStyle = JointStyle.BEVEL;
style.strokeStyle.capsStyle = CapsStyle.SQUARE;
// create reference style
var refStyle:GeometryStyle = new GeometryStyle();
refStyle.fill = GeometryStyle.NONE;
refStyle.strokeThickness = 0;
// draw main polyline
style.applyTo(this.graphics);
drawPolyline(5, 50);
// draw reference polyline
refStyle.applyTo(this.graphics);
drawPolyline(5, 50);
// draw polyline
function drawPolyline(pointCount:uint, radius:uint):void
{
// define polyline's parameters
var angle:Number = -90;
var rad2grad:Number = Math.PI / 180;
var delta:Number = 360 / pointCount;
var point:Point;
for (var i:uint = 0; i < pointCount; i++)
{
point = new Point(radius Math.cos(angle rad2grad), radius Math.sin(angle rad2grad));
point.offset(radius + 20, radius + 20);
if (i == 0) this.graphics.moveTo(point.x, point.y);
else this.graphics.lineTo(point.x, point.y);
angle += delta;
angle = angle > 360 ? angle - 360 : angle;
}
} You should see an orange polyline with square caps & bevel joint style after executing the code:
See also
| Property | Defined by | ||
|---|---|---|---|
| capsStyle : String = "round"
A value from the
CapsStyle class that specifies the type of caps at the end of lines. | StrokeStyle | ||
| jointStyle : String = "round"
A value from the
JointStyle class that specifies the type of joint appearance used at angles. | StrokeStyle | ||
| miterLimit : Number = 3
A number that indicates the limit at which a miter is cut off.
| StrokeStyle | ||
| noScale : String = "normal"
A value from the
LineScaleMode class that specifies which scale mode to use. | StrokeStyle | ||
| pixelHinting : Boolean = true
A Boolean value that specifies whether to hint strokes to full pixels.
| StrokeStyle | ||
| Method | Defined by | ||
|---|---|---|---|
|
StrokeStyle(param:Object = null)
StrokeStyle contructor.
| StrokeStyle | ||
![]() |
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 | |
![]() |
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
Abstract function.
| Style | |
| capsStyle | property |
public var capsStyle:String = "round"
A value from the CapsStyle class that specifies the type of caps at the end of lines.
Valid values are: CapsStyle.NONE, CapsStyle.ROUND, and CapsStyle.SQUARE.
If a value is not indicated, Flash uses round caps.
The default value is CapsStyle.ROUND.
| jointStyle | property |
public var jointStyle:String = "round"
A value from the JointStyle class that specifies the type of joint appearance used at angles.
Valid values are: JointStyle.BEVEL, JointStyle.MITER, and JointStyle.ROUND.
If a value is not indicated, Flash uses round joints.
The default value is JointStyle.ROUND.
| miterLimit | property |
public var miterLimit:Number = 3A number that indicates the limit at which a miter is cut off. Valid values range from 1 to 255 (and values outside of that range are rounded to 1 or 255).
This value is only used if the jointStyle is set to JointStyle.MITER.
The miterLimit value represents the length that a miter can extend beyond the point at which
the lines meet to form a joint. The value expresses a factor of the line thickness.
For example, with a miterLimit factor of 2.5 and a thickness of 10 pixels, the miter is cut off at 25 pixels.
The default value is 3.
| noScale | property |
public var noScale:String = "normal"
A value from the LineScaleMode class that specifies which scale mode to use.
Possible values include:
LineScaleMode.NORMAL — Always scale the line thickness when the object is scaled (the default). LineScaleMode.NONE — Never scale the line thickness. LineScaleMode.VERTICAL — Do not scale the line thickness if the object is scaled vertically only. LineScaleMode.HORIZONTAL — Do not scale the line thickness if the object is scaled horizontally only. The default value is LineScaleMode.NORMAL.
| pixelHinting | property |
public var pixelHinting:Boolean = trueA Boolean value that specifies whether to hint strokes to full pixels. This affects both the position of anchors of a curve and the line stroke size itself.
With pixelHinting set to true, Flash Player hints line widths to full pixel widths.
With pixelHinting set to false, disjoints can appear for curves and straight lines.
The default value is true.
| StrokeStyle | () | constructor |
public function StrokeStyle(param:Object = null)StrokeStyle contructor.
Creates new StrokeStyle object with the default parameters.
Properties defined in param object will override the default values.
param:Object (default = null) — Object that holds all the properites of a style you wish to override upon its creation.
|