MovieClip.lineStyle( ) Method | Flash 6 |
sets stroke thickness, color, and transparency for drawing at runtime |
The integer line point size, ranging from 0 to 255, where 0 is hairline. If not specified, lines are not drawn. Values below 0 are interpreted as 0; those above 255 are interpreted as 255.
The integer color of the line, normally supplied in RGB hexadecimal triplet notation—0xRRGGBB, where RR, GG, and BB are two-digit hex numbers representing Red, Green, and Blue. For example, the hex integer 0xFF0000 indicates red. Defaults to black if not supplied. For a complete discussion of RGB triplet notation, see the Color class.
An integer between 0 and 100 specifying the opacity (or, conversely, the transparency) of the shape as a percentage—0 is completely transparent, whereas 100 is completely opaque. Defaults to 100 if not supplied. Values above 100 are interpreted as 100; those below 0 are interpreted as 0.
The lineStyle( ) method sets the stroke thickness, color, and transparency for all lines and curves subsequently drawn in mc via the lineTo( ) and curveTo( ) methods. By default, no stroke is applied to drawings in mc. The lineStyle( ) method must be invoked explicitly for each new movie clip and after every call to clear( ), or no stroke will appear (although filled regions can still be drawn without a stroke).
The following examples are valid ways to modify the line style for drawing_mc:
drawing_mc.lineStyle() // Clears the style // (lines and curves not stroked) drawing_mc.lineStyle(1) // 1 pt solid black drawing_mc.lineStyle(1,0x00FF00) // 1 pt solid green drawing_mc.lineStyle(1,0x00FF00, 50) // 1 pt semi-transparent green
We may change the stroke at any time by calling lineStyle( ) again. For example, the following code draws a square with progressively thicker lines colored black, red, green, and blue:
this.createEmptyMovieClip("drawing_mc", 2); drawing_mc.lineStyle(1, 0x000000, 100); drawing_mc.lineTo(100, 0); drawing_mc.lineStyle(5, 0xFF0000, 100); drawing_mc.lineTo(100, 100); drawing_mc.lineStyle(10, 0x00FF00, 100); drawing_mc.lineTo(0, 100); drawing_mc.lineStyle(15, 0x0000FF, 100); drawing_mc.lineTo(0, 0);
A thickness of 0 sets the stroke to hairline (a one-pixel line that does not increase in thickness when the clip or movie is scaled up). To turn the stroke off completely, set thickness to undefined or call lineStyle( ) with no parameters. For example:
drawing_mc.lineStyle(undefined); // Turn off lines in drawing_mc drawing_mc.lineStyle(); // Same thing
Even if a line style is defined for a movie clip, we can move the drawing pen to a new location without drawing a line or curve using MovieClip.moveTo( ). When the clear( ) method is invoked to erase all drawings in a clip, the clip's line style reverts to undefined (no line).
MovieClip.beginFill( ), MovieClip.beginGradientFill( ), MovieClip.clear( ), MovieClip.curveTo( ), MovieClip.endFill( ), MovieClip.lineTo( ), MovieClip.moveTo( )