class com.senocular.drawing

DashedLine

Class Information

Author
Trevor McCauley, senocular.com
Version
1.0.2
Description
The DashedLine class provides a means to draw with standard drawing methods but allows you to draw using dashed lines. Dashed lines are continuous between drawing commands so dashes won't be interrupted when new lines are drawn in succession

Use a DashedLine instance just as you would use a movie clip to draw lines and fills using Flash's drawing API on a movie clip.

Usage
import com.senocular.drawing.DashedLine;
// create a DashedLine instance that draws in _root
// dashes will be 10px long, spaces between will be 5
var myDashedDrawing:DashedLine = new DashedLine(_root, 10, 5);
// draw a square with dashed lines
myDashedDrawing.moveTo(50, 50);
myDashedDrawing.lineTo(100, 50);
myDashedDrawing.lineTo(100, 100);
myDashedDrawing.lineTo(50, 100);
myDashedDrawing.lineTo(50, 50);
Constructors
DashedLine() Class constructor; creates a ProgressiveDrawing instance.
Properties
target The target movie clip in which drawings are to be made
_curveaccuracy A value representing the accuracy used in determining the length of curveTo curves.
Methods
setDash() Sets new lengths for dash sizes
getDash() Gets the current lengths for dash sizes
moveTo() Moves the current drawing position in target to (x, y).
lineTo() Draws a dashed line in target using the current line style from the current drawing position to (x, y); the current drawing position is then set to (x, y).
curveTo() Draws a dashed curve in target using the current line style from the current drawing position to (x, y) using the control point specified by (cx, cy). The current drawing position is then set to (x, y).
clear() Clears the drawing in target
lineStyle() Sets the lineStyle for target
beginFill() Sets a basic fill style for target
beginGradientFill() Sets a gradient fill style for target
endFill() Ends the fill style for target

Constructors

DashedLine()

function DashedLine(target:Object, onLength:Number, offLength:Number)
Class constructor; creates a ProgressiveDrawing instance.
Parameters:
targetThe target movie clip to draw in.
onLengthLength of visible dash lines.
offLengthLength of space between dash lines.

Properties

target

public var target:Object
The target movie clip in which drawings are to be made

_curveaccuracy

public var _curveaccuracy:Number
A value representing the accuracy used in determining the length of curveTo curves.

Methods

setDash()

public function setDash(onLength:Number, offLength:Number):Void
Sets new lengths for dash sizes
Parameters:
onLengthLength of visible dash lines.
offLengthLength of space between dash lines.
Returns:
nothing

getDash()

public function getDash(Void):Array
Gets the current lengths for dash sizes
Returns:
Array containing the onLength and offLength values respectively in that order

moveTo()

public function moveTo(x:Number, y:Number):Void
Moves the current drawing position in target to (x, y).
Parameters:
xAn integer indicating the horizontal position relative to the registration point of the parent movie clip.
Aninteger indicating the vertical position relative to the registration point of the parent movie clip.
Returns:
nothing

lineTo()

public function lineTo(x:Number,y:Number):Void
Draws a dashed line in target using the current line style from the current drawing position to (x, y); the current drawing position is then set to (x, y).
Parameters:
xAn integer indicating the horizontal position relative to the registration point of the parent movie clip.
Aninteger indicating the vertical position relative to the registration point of the parent movie clip.
Returns:
nothing

curveTo()

public function curveTo(cx:Number, cy:Number, x:Number, y:Number):Void
Draws a dashed curve in target using the current line style from the current drawing position to (x, y) using the control point specified by (cx, cy). The current drawing position is then set to (x, y).
Parameters:
cxAn integer that specifies the horizontal position of the control point relative to the registration point of the parent movie clip.
cyAn integer that specifies the vertical position of the control point relative to the registration point of the parent movie clip.
xAn integer that specifies the horizontal position of the next anchor point relative to the registration. point of the parent movie clip.
yAn integer that specifies the vertical position of the next anchor point relative to the registration point of the parent movie clip.
Returns:
nothing

clear()

public function clear(Void):Void
Clears the drawing in target
Returns:
nothing

lineStyle()

public function lineStyle(thickness:Number,rgb:Number,alpha:Number):Void
Sets the lineStyle for target
Parameters:
thicknessAn 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 undefined, a line is not drawn. If a value of less than 0 is passed, Flash uses 0. The value 0 indicates hairline thickness; the maximum thickness is 255. If a value greater than 255 is passed, the Flash interpreter uses 255.
rgbA hex color value (for example, red is 0xFF0000, blue is 0x0000FF, and so on) of the line. If a value isn’t indicated, Flash uses 0x000000 (black).
alphaAn integer that indicates the alpha value of the line’s color; valid values are 0–100. If a value isn’t indicated, Flash uses 100 (solid). If the value is less than 0, Flash uses 0; if the value is greater than 100, Flash uses 100.
Returns:
nothing

beginFill()

public function beginFill(rgb:Number,alpha:Number):Void
Sets a basic fill style for target
Parameters:
rgbA hex color value (for example, red is 0xFF0000, blue is 0x0000FF, and so on). If this value is not provided or is undefined, a fill is not created.
alphaAn integer between 0–100 that specifies the alpha value of the fill. If this value is not provided, 100 (solid) is used. If the value is less than 0, Flash uses 0. If the value is greater than 100, Flash uses 100.
Returns:
nothing

beginGradientFill()

public function beginGradientFill(fillType:String,colors:Array,alphas:Array,ratios:Array,matrix:Object):Void
Sets a gradient fill style for target
Parameters:
fillTypeEither the string "linear" or the string "radial".
colorsAn array of RGB hex color values to be used in the gradient (for example, red is 0xFF0000, blue is 0x0000FF, and so on).
alphasAn array of alpha values for the corresponding colors in the colors array; valid values are 0–100. If the value is less than 0, Flash uses 0. If the value is greater than 100, Flash uses 100.
ratiosAn array of color distribution ratios; valid values are 0–255. This value defines the percentage of the width where the color is sampled at 100 percent.
matrixA transformation matrix that is an object with one of two sets of properties.
Returns:
nothing

endFill()

public function endFill(Void):Void
Ends the fill style for target
Returns:
nothing

Page generated: 10:35 pm on September 3, 2010