class com.Graphic.RoundRectangle extends MovieClip{ static var symbolName : String = "__Packages.com.Graphic.RoundRectangle"; static var symbolOwner : Function = RoundRectangle; static var symbolLinked = Object.registerClass (symbolName, symbolOwner); public var x:Number = new Number(); // x position of fill public var y:Number = new Number(); // y position of fill public var w:Number = new Number(); // width of fill public var h:Number = new Number(); // height of fill public var r ; // corner radius of fill :: number or object {br:#,bl:#,tl:#,tr:#} public var c ; // hex color of fill :: number or array [0x######,0x######] public var alpha ; // alpha value of fill :: number or array [0x######,0x######] public var rot ; // rotation of fill :: number or matrix object {matrixType:"box",x:#,y:#,w:#,h:#,r:(#*(Math.PI/180))} public var gradient:String = new String(); // type of gradient "linear" or "radial" public var ratios ; // (optional :: default [0,255]) - specifies the distribution of colors :: array [#,#]; // x - x position of fill // y - y position of fill // w - width of fill // h - height of fill // r - corner radius of fill :: number or object {br:#,bl:#,tl:#,tr:#} // c - hex color of fill :: number or array [0x######,0x######] // alpha - alpha value of fill :: number or array [0x######,0x######] // rot - rotation of fill :: number or matrix object {matrixType:"box",x:#,y:#,w:#,h:#,r:(#*(Math.PI/180))} // gradient - type of gradient "linear" or "radial" // ratios - (optional :: default [0,255]) - specifies the distribution of colors :: array [#,#]; // (x,y,w,h,r,c,alpha,rot,gradient,ratios) function RoundRectangle (){ if (typeof r == "object") { var rbr = r.br //bottom right corner var rbl = r.bl //bottom left corner var rtl = r.tl //top left corner var rtr = r.tr //top right corner } else { var rbr = rbl = rtl = rtr = r; } // if color is an object then allow for complex fills if(typeof c == "object") { if (typeof alpha != "object") var alphas = [alpha,alpha]; else var alphas = alpha; if (ratios == undefined) var ratios = [ 0, 0xff ]; var sh = h *.7 if (typeof rot != "object") var matrix = {matrixType:"box", x:-sh, y:sh, w:w*2, h:h*4, r:rot * 0.0174532925199433 } else var matrix = rot; if (gradient == "radial") this.beginGradientFill( "radial", c, alphas, ratios, matrix ); else this.beginGradientFill( "linear", c, alphas, ratios, matrix ); } else if (c != undefined) { this.beginFill (c, alpha); } // Math.sin and Math,tan values for optimal performance. // Math.rad = Math.PI/180 = 0.0174532925199433 // r*Math.sin(45*Math.rad) = (r*0.707106781186547); // r*Math.tan(22.5*Math.rad) = (r*0.414213562373095); //bottom right corner r = rbr; var a = r - (r*0.707106781186547); //radius - anchor pt; var s = r - (r*0.414213562373095); //radius - control pt; this.moveTo ( x+w,y+h-r); this.lineTo ( x+w,y+h-r ); this.curveTo( x+w,y+h-s,x+w-a,y+h-a); this.curveTo( x+w-s,y+h,x+w-r,y+h); //bottom left corner r = rbl; var a = r - (r*0.707106781186547); var s = r - (r*0.414213562373095); this.lineTo ( x+r,y+h ); this.curveTo( x+s,y+h,x+a,y+h-a); this.curveTo( x,y+h-s,x,y+h-r); //top left corner r = rtl; var a = r - (r*0.707106781186547); var s = r - (r*0.414213562373095); this.lineTo ( x,y+r ); this.curveTo( x,y+s,x+a,y+a); this.curveTo( x+s,y,x+r,y); //top right r = rtr; var a = r - (r*0.707106781186547); var s = r - (r*0.414213562373095); this.lineTo ( x+w-r,y ); this.curveTo( x+w-s,y,x+w-a,y+a); this.curveTo( x+w,y+s,x+w,y+r); this.lineTo ( x+w,y+h-r ); if (c != undefined) this.endFill(); } }