Click here to Skip to main content
15,887,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Updated 22-Apr-16 3:59am

1 solution

I think it can be very simply achieved with a variable measuring elapsed time and a switch statement in the timer event handler:

C#
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;
  }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900