EasyManua.ls Logo

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

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...
542 Animation, Filters, and Drawings
To draw a curve:
1. Create a new Flash document and save it as curve.fla.
2. Add the following ActionScript to Frame 1 of the Timeline:
this.createEmptyMovieClip("circle_mc", 1);
with (circle_mc) {
lineStyle(4, 0x000000, 100);
beginFill(0xFF0000);
moveTo(200, 300);
curveTo(300, 300, 300, 200);
curveTo(300, 100, 200, 100);
curveTo(100, 100, 100, 200);
curveTo(100, 300, 200, 300);
endFill();
}
3.
Save your Flash document and select Control > Test Movie to test the Flash document.
This code uses the Drawing API to draw a circle on the Stage. The circle shape uses only
four calls to the
MovieClip.curveTo() method and therefore can look a little distorted.
For another example that uses the Drawing API to create a circle, see the procedure on
creating a circle under “Drawing specific shapes” on page 543 for code that uses eight calls
to the
MovieClip.curveTo() method to draw a more realistic circle.
To draw a triangle:
1. Create a new Flash document and save it as triangle.fla.
2. Add the following ActionScript to Frame 1 of the Timeline:
this.createEmptyMovieClip("triangle_mc", 1);
This code uses the MovieClip.createEmptyMovieClip() method to create an empty
movie clip on the Stage. The new movie clip is a child of an existing movie clip (in this
case, the main timeline).
3. Add the following ActionScript to Frame 1 of the Timeline, following the code you added
in the preceding step:
with (triangle_mc) {
lineStyle(5, 0xFF00FF, 100);
moveTo(200, 200);
lineTo(300, 300);
lineTo(100, 300);
lineTo(200, 200);
}
In this code, the empty movie clip (triangle_mc) calls drawing methods. This code
draws a triangle with 5-pixel purple lines and no fill.
4. Save your Flash document and select Control > Test Movie to test the Flash document.

Table of Contents

Related product manuals