Using line styles
The Flash Drawing API lets you specify a line style that Flash uses for subsequent calls to
MovieClip.lineTo()
with different parameters, as follows:
lineStyle(thickness:Number, rgb:Number, alpha:Number, pixelHinting:Boolean,
noScale:String, capsStyle:String, jointStyle:String, miterLimit:Number)
You can call
MovieClip.lineStyle()
styles for different line segments within a path.
For more information on using ActionScript to set line styles, see the following sections:
"Setting stroke and caps styles" on page 548
"Setting parameters of line styles" on page 549
Setting stroke and caps styles
Flash 8 includes several improvements to line drawing. New line parameters added in Flash
Player 8 are
pixelHinting
The following procedure demonstrates the difference between the three new caps styles in
Flash Player 8:
,
none
To set caps styles using ActionScript:
1.
Create a new Flash document and save it as capstyle.fla.
2.
Add the following ActionScript to Frame 1 of the Timeline:
// Set up grid movie clip.
this.createEmptyMovieClip("grid_mc", 50);
grid_mc.lineStyle(0, 0x999999, 100);
grid_mc.moveTo(50, 0);
grid_mc.lineTo(50, Stage.height);
grid_mc.moveTo(250, 0);
grid_mc.lineTo(250, Stage.height);
// line 1 (capsStyle: round)
this.createEmptyMovieClip("line1_mc", 10);
with (line1_mc) {
createTextField("label_txt", 1, 5, 10, 100, 20);
label_txt.text = "round";
lineStyle(20, 0x99FF00, 100, true, "none", "round", "miter", 0.8);
moveTo(0, 0);
lineTo(200, 0);
_x = 50;
_y = 50;
}
// line 2 (capsStyle: square)
this.createEmptyMovieClip("line2_mc", 20);
548
Animation, Filters, and Drawings
and
MovieClip.curveTo()
in the middle of drawing a path to specify different
,
,
noScale
capsStyle
, and
.
round
square
until you call
MovieClip.lineStyle()
,
, and
jointStyle
miterLimit
.
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?