WEB开发网
开发学院图形图像Flash [AS 功能代码教程06]AS绘图总结及补充 阅读

[AS 功能代码教程06]AS绘图总结及补充

 2009-05-30 12:07:22 来源:WEB开发网   
核心提示:本次课程,对之前学过的画线方法给予总结,[AS 功能代码教程06]AS绘图总结及补充,同时再加以补充总结:圆:_root.createEmptyMovieClip("MC",1);MC._x = 200;MC._y = 150;var R = 60;MC.moveTo(R*Math.cos(0),R

本次课程,对之前学过的画线方法给予总结,同时再加以补充

总结:

圆:

_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);
}

1 2 3  下一页

Tags:AS 功能 代码

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接