Package | flash.display |
Class | public final class JointStyle |
Inheritance | JointStyle Object |
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
joints
parameter of the
flash.display.Graphics.lineStyle()
method. The method supports three types of joints:
miter, round, and bevel, as the following example shows:
See also
Public Properties
Public Methods
Public Constants
Constant | Defined By | ||
---|---|---|---|
BEVEL : String = "bevel" [static]
Specifies beveled joints in the joints parameter of the
flash.display.Graphics.lineStyle() method. | JointStyle | ||
MITER : String = "miter" [static]
Specifies mitered joints in the joints parameter of the
flash.display.Graphics.lineStyle() method. | JointStyle | ||
ROUND : String = "round" [static]
Specifies round joints in the joints parameter of the
flash.display.Graphics.lineStyle() method. | JointStyle |
Constant Detail
BEVEL | Constant |
public static const BEVEL:String = "bevel"
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
Specifies beveled joints in the joints
parameter of the
flash.display.Graphics.lineStyle()
method.
MITER | Constant |
public static const MITER:String = "miter"
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
Specifies mitered joints in the joints
parameter of the
flash.display.Graphics.lineStyle()
method.
ROUND | Constant |
public static const ROUND:String = "round"
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
Specifies round joints in the joints
parameter of the
flash.display.Graphics.lineStyle()
method.
Examples ( How to use this example )
JointStyleExample.as
The following example uses the JointStyleExample class to show the result
of three different joint styles applied to three sets of joined lines. This task is accomplished by performing
the following steps:
- The properties of each line are set as follows:
- The line length is set to 80 pixels.
- The border color is set to orange.
- The border size is set to 30 pixels.
- The highlight color is set to gray.
- The highlight size is set to zero pixels.
- The alpha is set to 1, making it solid.
- The pixel hinting is set to false (strokes not hinted to full pixels).
- The line scale mode is set to normal, which scales the thickness.
- The border caps and miter limit are declared but not set, so the default values are used.
- The class constructor creates three sets of two connected line segments. The segments start at x = 0, y = 0
by calling the
doDrawCorner()
method three times using the three joint styles (miter, round, and bevel). Each of the three calls todoDrawCorner()
uses the joint style and properties previously listed to draw two connected line segments and associated line highlights. This is done by first creating a new Shape objectchild
and then using methods of the Graphics class to set the line style and draw the lines and highlights. Each instance ofchild
is added to the display list and promptly drawn on the stage. - The connected line segments are then redrawn by using the
refreshLayout()
method at y = 80 pixels and starting at x = 80 pixels, with a 25-pixel separation between the line segments.
package { import flash.display.DisplayObject; import flash.display.Graphics; import flash.display.JointStyle; import flash.display.LineScaleMode; import flash.display.Shape; import flash.display.Sprite; public class JointStyleExample extends Sprite { private var size:uint = 80; private var borderColor:uint = 0xFFCC00; private var borderSize:uint = 30; private var highlightColor:uint = 0x666666; private var highlightSize:uint = 0; private var gutter:uint = 25; private var borderAlpha:uint = 1; private var borderPixelHinting:Boolean = false; private var borderScaleMode:String = LineScaleMode.NORMAL; private var borderCaps:String; private var borderMiterLimit:uint; public function JointStyleExample() { doDrawCorner(JointStyle.MITER); doDrawCorner(JointStyle.ROUND); doDrawCorner(JointStyle.BEVEL); refreshLayout(); } private function doDrawCorner(jointStyle:String):void { var halfSize:uint = Math.round(size / 2); var child:Shape = new Shape(); child.graphics.lineStyle(borderSize, borderColor, borderAlpha, borderPixelHinting, borderScaleMode, borderCaps, jointStyle, borderMiterLimit); child.graphics.lineTo(0, 0); child.graphics.lineTo(size, 0); child.graphics.lineTo(halfSize, size); child.graphics.endFill(); child.graphics.moveTo(0, 0); child.graphics.lineStyle(highlightSize, highlightColor); child.graphics.lineTo(0, 0); child.graphics.lineTo(size, 0); child.graphics.lineTo(halfSize, size); addChild(child); } private function refreshLayout():void { var ln:uint = numChildren; var child:DisplayObject; var lastChild:DisplayObject = getChildAt(0); lastChild.x = size; lastChild.y = size; for (var i:uint = 1; i < ln; i++) { child = getChildAt(i); child.x = gutter + lastChild.x + lastChild.width; child.y = size; lastChild = child; } } } }
Fri Mar 19 2010, 02:45 AM -07:00