How do you make a movie clip play at a random time? And keep on playing at random times until the flash movie is over.
i did an experiment in this a while ago and used it on one of my creations, here is how it went.
create your movie clip, starting it on frame 2 and add a stop(); action to the first frame.
then, on the root timeline, add this bit of code (where lines_mc is whatever instance name you may choose):
[AS]
// start random flashing of lines_mc
// set minimum and maximum interval values in seconds
tMin = 20;
tMax = 400;
function move() {
lines_mc.gotoAndPlay(2);
//reset random interval
clearInterval(moveInt);
t = Math.round((Math.random()*(tMax - tMin)) + tMin)*1000;
moveInt = setInterval(move, t);
}
//set initial interval
moveInt = setInterval(move, 20000);[/AS]
change tMin and tMax variables to change the time in between playing of your movie clips. in this case, the minimum time between playing was 20 seconds, the maximum time was 400 seconds.
also, you can alter the “20000” in
[AS]//set initial interval
moveInt = setInterval(move, 20000);[/AS]
to alter the initial interval that the movie clip plays at.
hope that helps! if you have trouble, i’ll post the .fla i did this on.