Home > Tips and Tricks > Flash AS3 – Random Time Pause

Flash AS3 – Random Time Pause

May 19th, 2009

When your looking to create a delay say on multiple movie clips so that the animations, play at different times, but you need to have a stop state here’s some code that will make it easier.

This allows you to setup a time delay before playing the next frames so you can have different start times.

stop();
var timer:Timer = new Timer(Math.random() * (10000 – 2000) + 1000, 1);
timer.start();
timer.addEventListener(TimerEvent.TIMER_COMPLETE, hope);

function hope(event:TimerEvent):void{
play();
}

Tips and Tricks ,

Comments are closed.