EasyManua.ls Logo

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

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...
546 Animation, Filters, and Drawings
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.

Table of Contents

Related product manuals