Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I do this? 2

Status
Not open for further replies.

TigerGirl7

Programmer
Apr 8, 2003
152
US
Hey,

My movie clip contains a series of 40 keyframes. I want to program the clip to advance to a the next key frame every 10 seconds or so.

I could place the following actionscript on each keyframe:

function move()
{
nextFrame();
}
setInterval(move, 10000);

but if I ever want to change the interval rate, it would be a nightmare.

How can I create a control clip (i think that's what it's called) that would control the clip as described above in such a way that would make it simple to edit the rate.

any suggestions?

cheers,
jen
 
Use a variable instead of setting a time in setInterval...

First frame...

function pause(){
play();
clearInterval(timer);
};
my_var = 5000;
stop();
timer = setInterval(pause, my_var);

Then on each frame...

stop();
timer = setInterval(pause, my_var);

You can reset my_var anytime to another value. You could even load it up from a text file, and not have to edit the movie itself. If you're looping this, you should set the initial value of my_var on a first blank keyframe, and loop back to the second frame, otherwise if you've changed the value of my_var in the other frames, it will reset back to 5 seconds when it lands on the first frame.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top