AS3.0での矩形に角に丸みを付けた図形
RoundRectSample.as
package {
import flash.display.*;
//図形を表示する
public class RoundRectSample extends Sprite {
//コンストラクタ
public function RoundRectSample() {
//角丸矩形の追加
var rrect:Shape=makeRoundRect(140,200,20,0xEFD87A); //巾(w),高さ(h),塗り色(color)
x=50; //初期のX座標
y=50; //初期のY座標
addChild(rrect);
}
//関数(メソッド)定義
//角丸矩形の追加
private function makeRoundRect(w:uint,h:uint,ew:uint,color:uint):Shape {
var rrect:Shape=new Shape();
rrect.graphics.beginFill(color); //背景色
rrect.graphics.lineStyle(0,0xFF0000); //線幅・線色
rrect.graphics.drawRoundRect(100,50,w,h,ew);//初期+左上のXY座標,幅,高さ,角丸幅
rrect.graphics.endFill(); //塗り潰し終了
return rrect;
}
}
}

0