Flash AS3.0教程:好看的荷塘涟漪动画

作者:网络 来源:佚名 更新时间:2009-10-27 08:59:45 点击:
 

详细代码:
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);