550
Animation, Filters, and Drawings
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
lineStyle()
method,
rgb
, lets you control the color of the
current line segment as a number. By default, Flash draws black lines (
#000000
), although you
can specify different colors by setting a new hexidecimal color value using
0xRRGGBB
syntax.
In this syntax,
RR
is a red value (between
00
and
FF
),
GG
is a green value (
00
to
FF
), and
BB
is a
blue value (
00
to
FF
).
For example, you represent a red line as
0xFF0000
, a green line as
0x00FF00
, a blue line as
0x0000FF
, a purple line as
0xFF00FF
(red and blue), a white line as
#FFFFFF
, a gray line as
#999999
, and so on.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...