如何用Flash实现飘雪效果

    文章来源:万象互联 更新时间:2012-11-23 18:55:05
分享:

在flash里画一片雪,设为moveClip,起名snow,删除场景是的雪片,在库中链接,选“为第一帧导出”“为actionscript导出”起名snow,然后在第一帧写入如下代码即可:
var t:Timer;
t = new Timer(1000,10);
t.addEventListener(TimerEvent.TIMER,xue);
t.start();
function xue(e:TimerEvent):void {
var i:int;
for (i=0; i<=10; i ) {
var tt:snow=new snow();
addChild(tt);
var sj:uint=Math.random()*5>>0;
tt.x=Math.random()*550>>0;
tt.y=Math.random()*400>>0;
tt.width=sj;
tt.height=sj;
//tt.alpha=10;
tt.addEventListener(Event.ENTER_FRAME,moveY);
}
}
function moveY(e:Event) {
var speed:uint=e.target.width Math.random()*1>>0;
e.target.y =speed;
if (e.target.y>400) {
e.target.y=0;
}
}

文章来源:http://www.hulian.top,转载请注明!

版权说明:本站原创文章,由万象互联SEO优化发表.
本文地址:https://www.hulian.top/zixun/post/5441.html
在线咨询
  • 在线时间
  • 8:00-21:00