EasyManua.ls Logo

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

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 541
For more information on drawing with ActionScript, see the following topics:
“Using drawing methods to draw lines, curves, and shapes” on page 541
“Drawing specific shapes” on page 543
“Using complex gradient fills” on page 547
“Using line styles” on page 548
“Using Drawing API methods and scripting animation” on page 554
You can find a sample source file, drawingapi.fla, in the Samples folder on your hard disk,
which shows you how to use the Drawing API in a Flash application.
In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\DrawingAPI.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/DrawingAPI.
Using drawing methods to draw lines, curves, and
shapes
You can use the Flash Drawing API to dynamically create shapes on the Stage at runtime. You
can use these shapes to dynamically mask content, apply filters to them, or animate them
around the Stage. You can also use the Drawing API to create various drawing tools, which let
users use the mouse or keyboard to draw shapes on the SWF file.
To draw a line:
1. Create a new Flash document and save it as line.fla.
2. Add the following ActionScript to Frame 1 of the Timeline:
this.createEmptyMovieClip("line_mc", 10);
line_mc.lineStyle(1, 0x000000, 100);
line_mc.moveTo(0, 0);
line_mc.lineTo(200, 100);
line_mc._x = 100;
line_mc._y = 100;
This code draws a line from 0,0 on the Stage to 200,100. The line’s _x and _y coordinates
are then modified to reposition the line to 100,100 on the Stage.
3. Save your Flash document and select Control > Test Movie to test the SWF file.
To draw a more complex shape, continue calling the
MovieClip.lineTo() method and draw
a rectangle, square, or oval, as the following procedures show.

Table of Contents

Related product manuals