PDA

View Full Version : stopping timed movies



jondj24
September 29th, 2003, 11:16 AM
if i have a randomClips function that shows a range of swf files every 15seconds and wanted to create a button that could stop the auto change of the clips, what would be the script for that button if the script for the randomClips looks like this:



randomClips = new Array("d+l A_news.swf", "maashaven B_news.swf", "maashaven A_news.swf", "gipsy A_news.swf", "gipsy B_news.swf", "d+l B_news.swf", "gw A_news.swf", "gw B_news.swf", "soundscapes A_news.swf", "soundscapes B_news.swf", "fhwsf A_news.swf", "fhwsf B_news.swf");
function randomBackground() {
randomNumber = random(randomClips.length);
loadMovie(randomClips[randomNumber], "_root.mtClip");
}
randomBackground();
timeLimit = 15000;
// for example 15 seconds
startTime = getTimer();
actualTime = getTimer();
function timerReload() {
if (actualTime-startTime<=timeLimit) {
actualTime = getTimer();
} else {
randomBackground();
startTime = getTimer();
}
}
// creating an empty movie clip so I can use it's onEnterFrame event
this.createEmptyMovieClip("emptyClip", 1);
emptyClip.onEnterFrame = timerReload;


thanks.
jonathan

Voetsjoeba
September 29th, 2003, 01:51 PM
setInterval would be a better solution for this:



randomClips = new Array("d+l A_news.swf", "maashaven B_news.swf", "maashaven A_news.swf", "gipsy A_news.swf", "gipsy B_news.swf", "d+l B_news.swf", "gw A_news.swf", "gw B_news.swf", "soundscapes A_news.swf", "soundscapes B_news.swf", "fhwsf A_news.swf", "fhwsf B_news.swf");
function randomBackground() {
randomNumber = Math.round(Math.random()*(randomClips.length-1));
_root.mtClip.loadMovie(randomClips[randomNumber]);
}
timeLimit = 15000;
autoChange = setInterval(randomBackground,timeLimit);
bt.onRelease = function(){
clearInterval(autoChange);
}

:)