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

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

To create a rounded rectangle:
1.
Create a new Flash document and save it as roundrect.fla.
2.
Add the following ActionScript code to Frame 1 of the Timeline:
this.createEmptyMovieClip("rectangle_mc", 10);
rectangle_mc._x = 100;
rectangle_mc._y = 100;
drawRoundedRectangle(rectangle_mc, 240, 180, 20, 0x99FF00, 100);
function drawRoundedRectangle(target_mc:MovieClip, boxWidth:Number,
boxHeight:Number, cornerRadius:Number, fillColor:Number,
fillAlpha:Number):Void {
with (target_mc) {
beginFill(fillColor, fillAlpha);
moveTo(cornerRadius, 0);
lineTo(boxWidth - cornerRadius, 0);
curveTo(boxWidth, 0, boxWidth, cornerRadius);
lineTo(boxWidth, cornerRadius);
lineTo(boxWidth, boxHeight - cornerRadius);
curveTo(boxWidth, boxHeight, boxWidth - cornerRadius, boxHeight);
lineTo(boxWidth - cornerRadius, boxHeight);
lineTo(cornerRadius, boxHeight);
curveTo(0, boxHeight, 0, boxHeight - cornerRadius);
lineTo(0, boxHeight - cornerRadius);
lineTo(0, cornerRadius);
curveTo(0, 0, cornerRadius, 0);
lineTo(cornerRadius, 0);
endFill();
}
}
3.
Save the Flash document and select Control > Test Movie to test the document.
A green rectangle appears on the Stage that is 240 pixels wide and 180 pixels high with
20-pixel rounded corners. You can create multiple instances of rounded rectangles by
creating new movie clips using
custom
drawRoundedRectangle()
You can create a perfect circle using the Drawing API, as the following procedure shows.
544
Animation, Filters, and Drawings
MovieClip.createEmptyMovieClip()
function.
and calling your

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?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents