setTimeout!

This little function is very straight forward to use and can save huge amount of timeline spacing. If you often find yourself adding loads of frames to insert pauses in your animation - for example to display some text on screen, before it automatically moves on - then using this will really help.

Flash Timeline and ActionScript panelSimply add:

setTimeout(play, 2000);

stop();

setTimeout is a built in function within Flash, the first part “play” is the command you want to run when it’s done waiting - in this case it’s the built in function play(). The second part is how long to wait - this is done in milliseconds, so 2000 is 2 seconds.

And obviously don’t forget to stop the current timeline, otherwise there’s no point in pausing!

This is just the basics, the next step would be to call a custom function to do something more than just play - in this case your code would look like this:

setTimeout(Continue, 2000);

function Continue():void {
play();
}

stop();

The part we’ve added her is a custom function it can be called whatever you like (without spaces) - you only need to have this once within this timeline! So further pauses in this timeline would simply have the setTimeout line followed by the stop, no need to re-declare the custom function.

As an example of the above, have a look at this fla file to see examples of both approaches in action - the first to pause the timeline, the second and third to open and close some doors.

View an example swf here.