Flash AS3.0代码编写好看的荷塘涟漪动画
程序员文章站
2022-06-08 11:01:45
本教程是向大家介绍Flash AS3.0代码编写好看的荷塘涟漪动画,教程为两部分,一部分是涟漪动画的制作,二就是荷叶和荷花的绘制过程,喜欢的朋友可以一起来学习一下... 14-07-16...
本教程是向大家介绍flash as3.0代码编写好看的荷塘涟漪动画,教程为两部分,一部分是涟漪动画的制作,二就是荷叶和荷花的绘制过程,喜欢的朋友可以一起来学习一下。先来看看最终效果图:
详细的as代码:
复制代码
代码如下:stage.framerate=80;
function init(x1:number,y1:number) {
var mc:movieclip=new movieclip();
addchildat(mc,1);
mc.x=x1;
mc.y=y1;
mc.graphics.linestyle(0.5,0xbbffff,0.6);
mc.graphics.drawellipse(-1,-0.3,2,0.6);
mc.addeventlistener(event.enter_frame,frame);
var v0=0.5+0.3*math.random();
function frame(e) {
mc.scalex=mc.scaley+=v0;
mc.alpha>0?mc.alpha-=0.02:[mc.removeeventlistener(event.enter_frame,frame),removechild(mc),mc=null];
}
}
function xiayu() {
var timer:timer=new timer(200,2);
timer.addeventlistener(timerevent.timer,ontimer);
var mc:movieclip=new movieclip();
mc.graphics.beginfill(0xbbffff,0.8);
mc.graphics.drawellipse(-0.5,-2,1,4);
addchildat(mc,1);
mc.scalex=mc.scaley=0.7+0.3*math.random();
var x0=mc.x=50+math.random()*450;
mc.y=-10-20*math.random();
var y0=30+350*math.random();
mc.addeventlistener(event.enter_frame,frameb);
function frameb(e) {
if (mc.y<y0) {
mc.y+=5;
} else {
mc.removeeventlistener(event.enter_frame,frameb);
removechild(mc);
mc=null;
init(x0,y0);
timer.start();
}
}
function ontimer(e) {
init(x0,y0);
}
}
var t:timer=new timer(100,0);
t.addeventlistener(timerevent.timer,ont);
t.start();
function ont(e) {
xiayu();
xiayu();
}
var tu:hehua=new hehua();
addchild(tu);
var kj:movieclip=new kj ;
addchild(kj);
function init(x1:number,y1:number) {
var mc:movieclip=new movieclip();
addchildat(mc,1);
mc.x=x1;
mc.y=y1;
mc.graphics.linestyle(0.5,0xbbffff,0.6);
mc.graphics.drawellipse(-1,-0.3,2,0.6);
mc.addeventlistener(event.enter_frame,frame);
var v0=0.5+0.3*math.random();
function frame(e) {
mc.scalex=mc.scaley+=v0;
mc.alpha>0?mc.alpha-=0.02:[mc.removeeventlistener(event.enter_frame,frame),removechild(mc),mc=null];
}
}
function xiayu() {
var timer:timer=new timer(200,2);
timer.addeventlistener(timerevent.timer,ontimer);
var mc:movieclip=new movieclip();
mc.graphics.beginfill(0xbbffff,0.8);
mc.graphics.drawellipse(-0.5,-2,1,4);
addchildat(mc,1);
mc.scalex=mc.scaley=0.7+0.3*math.random();
var x0=mc.x=50+math.random()*450;
mc.y=-10-20*math.random();
var y0=30+350*math.random();
mc.addeventlistener(event.enter_frame,frameb);
function frameb(e) {
if (mc.y<y0) {
mc.y+=5;
} else {
mc.removeeventlistener(event.enter_frame,frameb);
removechild(mc);
mc=null;
init(x0,y0);
timer.start();
}
}
function ontimer(e) {
init(x0,y0);
}
}
var t:timer=new timer(100,0);
t.addeventlistener(timerevent.timer,ont);
t.start();
function ont(e) {
xiayu();
xiayu();
}
var tu:hehua=new hehua();
addchild(tu);
var kj:movieclip=new kj ;
addchild(kj);
教程结束,以上就是flash as3.0代码编写好看的荷塘涟漪动画,希望大家看完之后会有一定的帮助,谢谢大家观看本教程!