PDA

View Full Version : function to delay frame


chrismol
10-17-2005, 05:31 AM
I am looking for a way to simply delay the timeline on a frame for a certain amount of seconds or milliseconds. Similar to setTimeOut() function in javascript.

Is setInterval() the function to do this? If so, please provide some sample code.

I'm looking for this code because I've got a Flash movie with many layers and I want the ability to control the length of time a layer displays, separate from the timeline and the frames per second. It seems silly to control the time a layer displays simply by adding frames. It's inefficient and must add to file size.

Any help much appreciated.

C

L-iNC
10-17-2005, 11:15 PM
Maybe this will do it...

Put this code to the frame you want to delay
//This code delays the movie playback for given time
onEnterFrame = function() {
function delay() {
nextFrame();
};

setInterval(delay, 1000)//The second parameter of setInterval is given in milliseconds so 1000 milliseconds is 1 second.
};
stop();

and this code should go to the next frame...

//clear the interval
onEnterFrame.clearInterval(delay);

I got this code to work, but I have a feeling there's a better way of delaying timeline. :D