本次课程,对之前学过的画线方法给予总结,同时再加以补充
总结:
圆:
_root.createEmptyMovieClip("MC",1);
MC._x = 200;
MC._y = 150;
var R = 60;
MC.moveTo(R*Math.cos(0),R*Math.sin(0));
MC.lineStyle(2);
for (n=1; n < 360; n++) {
var angle = n*Math.PI/180;
var tox = R*Math.cos(angle);
var toy = R*Math.sin(angle);
MC.lineTo(tox,toy);
}
椭圆:
_root.createEmptyMovieClip("MC",1);
MC._x = 200;
MC._y = 150;
var W = 50;
var H = 30;
MC.moveTo(W*Math.cos(0),H*Math.sin(0));
MC.lineStyle(2);
for (n=1; n < 360; n++) {
var angle = n*Math.PI/180;
var tox = W*Math.cos(angle);
var toy = H*Math.sin(angle);
MC.lineTo(tox,toy);
}
螺旋线:
_root.createEmptyMovieClip("MC",1);
MC._x = 200;
MC._y = 150;
var R = 10;
var A = 3;
MC.moveTo(0,0);
MC.lineStyle(2);
for (n=1; n < 360; n++) {
var angle = A*n*Math.PI/180;
var tox = angle*R*Math.cos(angle);
var toy = angle*R*Math.sin(angle);
MC.lineTo(tox,toy);
}
多边型:
_root.createEmptyMovieClip("MC",1);
MC._x = 200;
MC._y = 150;
var R = 50;
var sides = 5;
var angle = (360*Math.PI/180)/sides;
var MA:Array = new Array();
for (i=0; i <= sides; i++) {
MA[i] = i*angle;
}
MC.moveTo(R*Math.cos(MA[0]),R*Math.sin(MA[0]));
MC.lineStyle(2);
for (n=1; n <= sides; n++) {
var tox = R*Math.cos(MA[n]);
var toy = R*Math.sin(MA[n]);
MC.lineTo(tox,toy);
}