To create a hairline stroke:
1.
Create a new Flash document and save it as hairline.fla.
2.
Add the following ActionScript to Frame 1 of your Timeline:
this.createEmptyMovieClip("drawing_mc", 10);
// create a red, hairline thickness line
drawing_mc.lineStyle(0, 0xFF0000, 100);
drawing_mc.moveTo(0, 0);
drawing_mc.lineTo(200, 0);
drawing_mc.lineTo(200, 100);
// create a blue line with a 1 pixel thickness
drawing_mc.lineStyle(1, 0x0000FF, 100);
drawing_mc.lineTo(0, 100);
drawing_mc.lineTo(0, 0);
drawing_mc._x = 100;
drawing_mc._y = 100;
The preceding code uses the Drawing API to draw two lines on the Stage. The first line is
red and has a thickness of 0, indicating a hairline thickness, the second line is blue and has
a thickness of 1 pixel.
3.
Save the Flash document and select Control > Test Movie to test the SWF file.
Initially, both the red and blue lines look exactly the same. If you right-click in the SWF
file and select Zoom In from the context menu, the red line always appears as a 1-pixel
line; however, the blue line grows larger each time you zoom in to the SWF file.
Setting line color (rgb)
The second parameter in the
current line segment as a number. By default, Flash draws black lines (
can specify different colors by setting a new hexidecimal color value using
In this syntax,
is a red value (between
RR
blue value (
to
).
00
FF
For example, you represent a red line as
, a purple line as
0x0000FF
, and so on.
#999999
550
Animation, Filters, and Drawings
method,
lineStyle()
and
00
0xFF0000
(red and blue), a white line as
0xFF00FF
, lets you control the color of the
rgb
),
is a green value (
FF
GG
, a green line as
0x00FF00
#FFFFFF
), although you
#000000
syntax.
0xRRGGBB
to
), and
is a
00
FF
BB
, a blue line as
, a gray line as
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?