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()
For another example that uses the Drawing API to create a circle, see the procedure on
creating a circle under
to the
MovieClip.curveTo()
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
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 (
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.
542
Animation, Filters, and Drawings
"Drawing specific shapes" on page 543
method to draw a more realistic circle.
MovieClip.createEmptyMovieClip()
triangle_mc
method and therefore can look a little distorted.
method to create an empty
) calls drawing methods. This code
for code that uses eight calls
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?
Questions and answers