Drawing with ActionScript
549
with (line2_mc) {
createTextField("label_txt", 1, 5, 10, 100, 20);
label_txt.text = "square";
lineStyle(20, 0x99FF00, 100, true, "none", "square", "miter", 0.8);
moveTo(0, 0);
lineTo(200, 0);
_x = 50;
_y = 150;
}
// line 3 (capsStyle: none)
this.createEmptyMovieClip("line3_mc", 30);
with (line3_mc) {
createTextField("label_txt", 1, 5, 10, 100, 20);
label_txt.text = "none";
lineStyle(20, 0x99FF00, 100, true, "none", "none", "miter", 0.8);
moveTo(0, 0);
lineTo(200, 0);
_x = 50;
_y = 250;
}
The preceding code dynamically creates four movie clips and uses the Drawing API to
create a series of lines on the Stage. The first movie clip contains two vertical lines, one at
50 pixels and the other at 250 pixels on the x-axis. The next three movie clips each draw a
green line on the Stage and sets their capsStyle to round, square, or none.
3.
Select Control > Test Movie to test the document.
The different caps styles appear on the Stage at runtime.
Setting parameters of line styles
You can set the parameters of line styles to change the appearance of your strokes. You can use
parameters to change the thickness, color, alpha, scale, and other attributes of the line style.
Setting line thickness
The
thickness
parameter of the
MovieClip.lineStyle()
method lets you specify the
thickness of the line drawn in points as a number. You can draw a line any thickness between
0 and 255 points wide, although setting the thickness to 0 creates what is called a
hairline
thickness
, where the stroke is always 1 pixel, regardless of whether the SWF file is zoomed in
or resized.
The following procedure demonstrates the difference between a standard 1-pixel thickness
line and a hairline thickness line.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...