flash问题。在下面代码中如何控制下雪在50帧处开始,100帧处停止?

来源:百度知道 编辑:UC知道 时间:2024/05/27 03:18:05
var sj:Timer =new Timer(Math.random()*300+100,100);
sj.addEventListener(TimerEvent.TIMER ,sjcd);
function sjcd(event:TimerEvent) {
var xh:xh_mc=new xh_mc();
addChild(xh);
xh.x=Math.random()*550;
xh.y=Math.random()*200;
xh.alpha=Math.random()*1+0.2;
xh.scaleX=Math.random()*0.5+0.5;
xh.scaleY=Math.random()*0.5+0.5;
}
sj.start();

可以代码放在50帧处开始

不能在100帧上写stop的

var abc=0//定义一个变量abc
var sj:Timer =new Timer(Math.random()*300+100,100);
sj.addEventListener(TimerEvent.TIMER ,sjcd);
function sjcd(event:TimerEvent) {
var xh:xh_mc=new xh_mc();
addChildAt(xh,abc);//稍作修改,用变量abc
xh.x=Math.random()*550;
xh.y=Math.random()*200;
xh.alpha=Math.random()*1+0.2;
xh.scaleX=Math.random()*0.5+0.5;
xh.scaleY=Math.random()*0.5+0.5;
abc++;
}
sj.start();

this.addEventListener(Event.ENTER_FRAME, bcd);
function bcd(event:Event){
if(currentFrame>100){
for(var i=0,i<abc;i++){
getChildAt(i).visible=false;}
removeEventListener(TimerEvent.TIMER,sjcd);
removeEventListener(Event.ENTER_FRAME, bcd;
}
}
试试看对不对咯

sj.start();
把这段代码移到50帧上去
在100帧上加上
sj.stop();

sj.start();开始
sj.stop();结束