EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 549

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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.

Table of Contents

Related product manuals