as3计时器播放movieclip [英] as3 timer play movieclip
问题描述
你好
i正在做一个使用计时器来播放影片剪辑的项目
无论如何当计时器的监听器触发功能时,同时播放多个视频?
例如:
var mcList:array = [];
mcList = [mc1,mc2,m3,mc4,mc5,mc6]; //仅举个例子,这个数组用于存储movieclip
var mcTimer:Timer = new Timer(1000);
mcTimer.addEventListener (TimerEvent.TIMER,ani);
mcTimer.start();
private Function ani(e:TimerEvent):void {
/ *但是要播放mc1,mc2在第1秒
*第2秒播放mc3,mc4,mc5
*和lasy play mc6 * /
}
任何想法?
hello
i am doing a project which using timer to play the movieclips
is there anyway to play more then one video at the same time when the timer's listener trigger the function?
example :
var mcList :array = [ ];
mcList = [ mc1 , mc2 , m3 , mc4 , mc5, mc6 ] ; // just for an example this array used to store movieclip
var mcTimer :Timer = new Timer(1000);
mcTimer.addEventListener(TimerEvent.TIMER, ani );
mcTimer.start();
private Function ani(e:TimerEvent):void{
/*but to play the mc1 , mc2 in 1st second
*2nd second play mc3 , mc4 , mc5
*and lasy play mc6*/
}
any idea?
推荐答案
我认为它可以通过可变测量经过时间和计时器事件处理程序中的switch语句非常简单地实现:
I think it can be very simply achieved with a variable measuring elapsed time and a switch statement in the timer event handler:
var mcList :array = [ ];
mcList = [ mc1 , mc2 , m3 , mc4 , mc5, mc6 ] ;
var mcTimer :Timer = new Timer(1000);
mcTimer.addEventListener(TimerEvent.TIMER, ani );
var elapsed:int=0;
mcTimer.start();
private Function ani(e:TimerEvent):void{
switch (++elapsed) {
case 1: // After the first second elapsed
mc1.play();
mc2.play();
break;
case 2: // After the second second elapsed
mc3.play();
mc4.play();
mc5.play();
break;
case 3: // After the third second elapsed
mc6.play();
mcTimer.stop(); // Stop the timer if it is no longer needed
break;
}
}
这篇关于as3计时器播放movieclip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!