ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
flash.display 

JointStyle  - AS3

Packageflash.display
Classpublic final class JointStyle
InheritanceJointStyle Inheritance Object

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9

The JointStyle class is an enumeration of constant values that specify the joint style to use in drawing lines. These constants are provided for use as values in the 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:

MITER, ROUND, and BEVEL

View the examples

Related API Elements



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
Public Methods
 MethodDefined By
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Public Constants
 ConstantDefined 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.

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:
  1. 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.
  2. 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 to doDrawCorner() 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 object child and then using methods of the Graphics class to set the line style and draw the lines and highlights. Each instance of child is added to the display list and promptly drawn on the stage.
  3. 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;
            }
        }
    }
}