Login / Sign Up

Your cart has 3 products totalling 214.00 USD

Create rectangles with rounded corners radius in ActionScript 2

 

 

Here's a function with which you're able to create a rectangle with rounded corner:

 

function drawRoundedRectangle(mc:MovieClip, rectWidth:Number, rectHeight:Number, cornerRadius:Number, fillColor:Number, fillAlpha:Number, lineThickness:Number, lineColor:Number, lineAlpha:Number) {
  with (mc) {
    beginFill(fillColor, fillAlpha);
    lineStyle(lineThickness, lineColor, lineAlpha);
    moveTo(cornerRadius, 0);
    lineTo(rectWidth - cornerRadius, 0);
    curveTo(rectWidth, 0, rectWidth, cornerRadius);
    lineTo(rectWidth, cornerRadius);
    lineTo(rectWidth, rectHeight - cornerRadius);
    curveTo(rectWidth, rectHeight, rectWidth - cornerRadius, rectHeight);
    lineTo(rectWidth - cornerRadius, rectHeight);
    lineTo(cornerRadius, rectHeight);
    curveTo(0, rectHeight, 0, rectHeight - cornerRadius);
    lineTo(0, rectHeight - cornerRadius);
    lineTo(0, cornerRadius);
    curveTo(0, 0, cornerRadius, 0);
    lineTo(cornerRadius, 0);
    endFill();
  }
}

 

 

  • COMMENTS
  • SEARCH COMMENTS
snowcat

on the contrary, for Flash 8 was originally written

Posted 9 Months Ago
chrisn

//website not yet up to scratch

with flash 8 the with does not work

Posted 9 Months Ago
abenson

Perfect, and very concise. This is the best script on the web for drawing rounded rectangles.

Posted 1 Year Ago

Leave a Reply

Only alphanumeric characters allowed
Please type a message!
Format your comments using Textile: *bold*, _italic_, "link text":address, @code@