MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 546

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

To create a fancy triangle:
1.
Create a new Flash document and save it as fancytriangle.fla.
2.
Add the following ActionScript to Frame 1 of the Timeline:
this.createEmptyMovieClip("triangle_mc", 10);
triangle_mc._x = 100;
triangle_mc._y = 100;
drawTriangle(triangle_mc, 100, 0x99FF00, 100);
function drawTriangle(target_mc:MovieClip, sideLength:Number,
fillColor:Number, fillAlpha:Number):Void {
var tHeight:Number = sideLength * Math.sqrt(3) / 2;
with (target_mc) {
beginFill(fillColor, fillAlpha);
moveTo(sideLength / 2, 0);
lineTo(sideLength, tHeight);
lineTo(0, tHeight);
lineTo(sideLength / 2, 0);
endFill();
}
}
The Drawing API draws an equilateral triangle on the Stage and fills it with the specified
fill color and amount of alpha (transparency).
3.
Save the Flash document and select Control > Test Movie to test the Flash document.
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.
546
Animation, Filters, and Drawings

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

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?

This manual is also suitable for:

Flash 8

Table of Contents