//第一帧动作 import flash.events.Event; for(var k:int=0;k<90;k++) { var xuehua:xue= new xue(); xuehua.alpha = Math.random()+.3; xuehua.height = xuehua.width = Math.random()*6+5; xuehua.x=Math.random()*550; xuehua.y=Math.random()*400; piaoxuekongjian.addChild(xuehua); } addEventListener(Event.ENTER_FRAME,webcyz); function webcyz(e:Event) { for(var k:int;k<3;k++) { var xuehua:xue= new xue(); xuehua.alpha = Math.random()+.3; xuehua.height = xuehua.width = Math.random()*6+5; xuehua.x=Math.random()*550; piaoxuekongjian.addChild(xuehua); } //trace(piaoxuekongjian.numChildren); for(var i:int=0;i<piaoxuekongjian.numChildren;i++) { var mc:xue = xue(piaoxuekongjian.getChildAt(i)); if(mc.y>400) { piaoxuekongjian.removeChild(mc); i--; } else { mc.y+=Math.random()*6; mc.x+=(Math.random()-.5)*5; } } }
//项目库中雪花的子类
package { import flash.display.MovieClip; public class xue extends MovieClip { public function xue() { // constructor code } } }