用FlashAS实现画图的周详讲解(5)
2008-04-02 11:06:20来源:互联网 阅读 ()
// 通过心脏线的方程定义起点的y坐标
c = daxiao*(2*Math.cos((n 1)*Math.PI/180)
Math.cos(2*((1 n)*Math.PI/180)));
d = daxiao*(2*Math.sin((n 1)*Math.PI/180)
Math.sin(2*((1 n)*Math.PI/180)));
// 同理定义终点的经x,y坐标
createEmptyMovieClip("yuan", n);
// 创建一个空影片yuan
with (yuan) {
lineStyle(0.5, 0x000000, 100);
// 定义线的大小、颜色、透明度
moveTo(a 200, b 150);
lineTo(c 200, d 150);
// 从起点到终点画一条线,并把图像的中央点定为(200,150)
}
if (n<=360) {
n = n 1;
}
};
画螺旋线
代码:
_root.onEnterFrame = function() {
a = (10 0.1*n)*Math.cos(n*Math.PI/180);
b = (10 0.1*n)*Math.sin(n*Math.PI/180);
c = (10 0.1*n)*Math.cos((n 1)*Math.PI/180);
d = (10 0.1*n)*Math.sin((n 1)*Math.PI/180);
createEmptyMovieClip("yuan", n);
with (yuan) {
lineStyle(2, 0x000000, 50);
moveTo(a 200, b 150);
lineTo(c 200, d 150);
}
if (n<=900) {
n = n 1;
}
};
旋转的长方体
代码:
a = 50*Math.cos(n*Math.PI/180);
b = 100*Math.sin(n*Math.PI/180);
c1 = 300;
c2 = 200;
_root.createEmptyMovieClip("triangle", 1);
with (_root.triangle) {
lineStyle(1, 0x000000, 50);
moveTo(a c1, b c2);
lineTo(50*math.cos((n 90)*math.pi/180)
c1,100*math.sin((n 90)*math.pi/180) c2);
lineTo(50*math.cos((n 180)*math.pi/180)
c1,100*math.sin((n 180)*math.pi/180) c2);
lineTo(50*math.cos((n 270)*math.pi/180)
c1,100*math.sin((n 270)*math.pi/180) c2);
lineTo(50*math.cos((n 360)*math.pi/180)
c1,100*math.sin((n 360)*math.pi/180) 200);
lineStyle(1, 0x000000, 50);
moveTo(a 200, b 100);
lineTo(50*math.cos((n 90)*math.pi/180)
200,100*math.sin((n 90)*math.pi/180) 100);
lineTo(50*math.cos((n 180)*math.pi/180)
200,100*math.sin((n 180)*math.pi/180) 100);
lineTo(50*math.cos((n 270)*math.pi/180)
200,100*math.sin((n 270)*math.pi/180) 100);
lineTo(50*math.cos((n 360)*math.pi/180)
200,100*math.sin((n 360)*math.pi/180) 100);
lineStyle(1, 0x000000, 30);
moveTo(a 200, b 100);
lineTo(a c1, b c2);
moveTo(50*math.cos((n 90)*math.pi/180)
c1,100*math.sin((n 90)*math.pi/180) c2);
lineTo(50*math.cos((n 90)*math.pi/180)
200,100*math.sin((n 90)*math.pi/180) 100);
moveTo(50*math.cos((n 180)*math.pi/180)
c1,100*math.sin((n 180)*math.pi/180) c2);
lineTo(50*math.cos((n 180)*math.pi/180)
200,100*math.sin((n 180)*math.pi/180) 100);
moveTo(50*math.cos((n 270)*math.pi/180)
c1,100*math.sin((n 270)*math.pi/180) c2);
lineTo(50*math.cos((n 270)*math.pi/180)
200,100*math.sin((n 270)*math.pi/180) 100);
}
用as做烛光,相当逼真。
代码:
offsetX = 275;
offsetY = 100;
left = 0;
right = 0;
top = 0;
leftGoal = 0;
rightGoal = 0;
topGoal = 0;
rate = .2;
decay = .9;
for (var i = 0; i<shapes.length; i ) {
var name = "flame" i;
createEmptyMovieClip(name, i);
_root[name]._x = offsetX;
_root[name]._y = offsetY;
_root[name].offset = parseInt(shapes[i].split("|")[0]);
_root[name].fade = parseInt(shapes[i].split("|")[1]);
}
createEmptyMovieClip("heat", i);
heat._x = offsetX;
heat._y = offsetY;
checkEdge = function (cur, side, dist) {
change = 0;if (cur>side) {
change -= Math.random()*dist;
} else if (cur<-side) {
change = Math.random()*dist;
}
return change;
};
onEnterFrame = function () {
leftGoal = Math.random()*6-3;
leftGoal = checkEdge(leftGoal,10, 3);
rightGoal = Math.random()*6-3;
rightGoal = checkEdge(rightGoal, 10,3);
topGoal = Math.random()*8-4;
topGoal = checkEdge(topGoal, 15, 4);
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
下一篇: 新浪/闪客帝国图片效果解析
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash
