EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Drawing Shapes with Actionscript

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 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 shapes with ActionScript 131
Drawing shapes with ActionScript
You can use methods of the MovieClip class to draw lines and fills on the Stage. This allows you
to create drawing tools for users and to draw shapes in the movie in response to events. The
drawing methods are
beginFill(), beginGradientFill(), clear(), curveTo(), endFill(),
lineTo(), lineStyle(), and moveTo().
You can use the drawing methods with any movie clip. However, if you use the drawing methods
with a movie clip that was created in authoring mode, the drawing methods execute before the
clip is drawn. In other words, content that is created in authoring mode is drawn on top of
content drawn with the drawing methods.
You can use movie clips with drawing methods as masks; however, as with all movie clip masks,
strokes are ignored.
To draw a shape:
1 Use createEmptyMovieClip() to create an empty movie clip on the Stage.
The new movie clip is a child of an existing movie clip or of the main Timeline, as in the
following example:
_root.createEmptyMovieClip ("triangle", 1);
2 Use the empty movie clip to call drawing methods.
The following example draws a triangle with 5-point magenta lines and no fill:
with (_root.triangle) {
lineStyle (5, 0xff00ff, 100);
moveTo (200, 200);
lineTo (300, 300);
lineTo (100, 300);
lineTo (200, 200);
}
For detailed information on these methods, see their entries in Chapter 12, ā€œActionScript
Dictionary,ā€ on page 205.

Table of Contents

Related product manuals