Flash AS3.0做出来的荷塘涟漪动画及源码分享。本教程是向大家介绍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代码编写好看的荷塘涟漪动画,希望大家看完之后会有一定的帮助,谢谢大家观看本教程!
本文地址:http://www.45fan.com/bcdm/11102.html