These two days in the study about as drawing problems, after some toss finally came out, (part of the code from programming Macromedia Flash MX)
As:
MovieClip.prototype.drawRegAng = function (x, y, R, num, rotation) {
/* parameter description: x,y: Center coordinate of polygon; R: Polygon radius; num: number of polygon edges; The last one is the rotation angle */
var tangle = (rotation-90) *math.pi/180;
var angle = 2*math.pi/num;
var sin = math.sin;
var cos = math.cos;
num++;
this.moveto (X+r*cos (Tangle), Y+r*sin (tangle));
while (num--) {
tangle + = angle;
This.lineto (X+r*cos (Tangle), Y+r*sin (tangle));
}
};
This.createemptymovieclip ("loader", 100);
Loader.linestyle (0, 0x000000);
//initialization variable
var r=50,num=5,rota=0;
var x = stage.width/2, y = STAGE.HEIGHT/2;
Loader.drawregang (x, y, R, Num, rota);
Numchange=new Object ();
Numchange.change=function (evt) {
Num=evt.target.value;
}
Rchange=new Object ();
Rchange.change=function (evt) {
R=evt.target.value;
}
Rotachange=new Object ();
Rotachange.change=function (evt) {
Rota=evt.target.value;
}
Bian.addeventlistener ("Change", Numchange);
Jiaodu.addeventlistener ("Change", Rotachange);
Banjing.addeventlistener ("Change", Rchange);
function clicked () {
Loader.clear ();
Loader.linestyle (0, 0x000000);
Loader.drawregang (x, y, R, Num, rota);
}
Rsubmit.addeventlistener ("Click", clicked);
Circular:
As:
Movieclip.prototype.drawoval=function (X,y,rx,ry) {
This.moveto (X+rx,y);
This.curveto (Rx+x,0.4142*ry+y,0.7071*rx+x,0.7071*ry+y);
This.curveto (0.4142*rx+x,ry+y,x,ry+y);
This.curveto ( -0.4142*rx+x,ry+y,-0.7071*rx+x,0.7071*ry+y);
This.curveto (-rx+x,0.4142*ry+y,-rx+x,y);
This.curveto (-rx+x,-0.4142*ry+y,-0.7071*rx+x,-0.7071*ry+y);
This.curveto ( -0.4142*rx+x,-ry+y,x,-ry+y);
This.curveto (0.4142*rx+x,-ry+y,0.7071*rx+x,-0.7071*ry+y);
This.curveto (Rx+x,-0.4142*ry+y,rx+x,y);
}