Monday, September 15, 2008

Pausing the timeline in Flash - Simple code insert

This is so basic but it saves masses of long drawn out timelines where you can find anything.

Drop the following into the first frame of your timeline (in a new layer or actions layer if that is how you work), and call it whenever needed.
Call it by adding a keyframe with paused(10) whenever you need to pause the timeline - in this case the pause is 10 seconds... how simple is that?
function paused(sec) {
stop();
var i = sec - 1;
var t = setInterval(function () {
if (i == 0) {
clearInterval(t);
play();
}
i--;
}, 1000);
}

No comments: