// drawRoundRect // 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 [#,#]; //function drawRoundRect(x,y,w,h,r,c,alpha,rot,gradient,ratios) MovieClip.prototype.drawRoundRect= function(x,y,w,h,r,c,alpha,rot,gradient,ratios) { 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(); } /* MovieClip.prototype.draw3dRectBorder = function (c1:Number, c2:Number, c3:Number, c4:Number,c5:Number,c6:Number):Void { //var w:Number = width; //var h:Number = height; var w:Number = 100; var h:Number = 100; beginFill(c1); drawRect(0,0,w,h); drawRect(1,0,w-1,h); endFill(); //outsidetop beginFill(c2); drawRect(1,0,w-1,1); endFill(); //outsidebottom beginFill(c3); drawRect(1,h -1,w-1,h); endFill(); //insidetop beginFill(c4); drawRect(1,1,w-1,2); endFill(); //insidebottom beginFill(c5); drawRect(1,h-2,w-1,h-1); endFill(); //insidesides beginFill(c6); drawRect(1,2,w-1,h-2); drawRect(2,2,w-2,h-2); endFill(); function drawRect (x1:Number, y1:Number, x2:Number, y2:Number):Void { moveTo(x1,y1); lineTo(x2,y1); lineTo(x2,y2); lineTo(x1,y2); lineTo(x1,y1); } } */