View Full Version : multiple movie loading problem.... aaarrrgh!
LoneJeeper
07-11-2006, 03:56 PM
Ok, i've got 15 movies in my library, i want one to load randomly, play, unload and another to load randomly, play, unload and so on.
here's my code:
frame1:
bg2.stop();
bg2.unloadMovie(); (<-- for testing)
num = 15; //>total num of all swfs by 1
Math.floor;
ranNum = Math.round(Math.random()*num);
attachMovie(ranNum+"_done.swf", "bg2", _root.getNextHighestDepth());
bg2.play();
frame 500:
bg2.unloadmovie();
gotoandplay(1);
it does okay for the first movie, but then it loads the next one right over top. what's wrong?
lj
sophistikat
07-17-2006, 03:13 PM
i think its better to use an array to randomize the order of your movieclips and we'll make sure the same movieclip won't be called twice// create our array with the names of our movieclips
var mcs:Array = ['mov1' + 'mov2' + 'mov3' + 'mov4' + 'mov5' + 'mov6' + 'mov7' + 'mov8' + 'mov9' + 'mov10' + 'mov11' + 'mov12' + 'mov13' + 'mov14' + 'mov15'];
// scramble our array
mcs.sort(scramble);
// create our scramble function
function scramble() {
return Math.floor(Math.random() * 2);
}
// create our count variables
var count = 0;now that we've setup and scramble our array, we can start loading them and unloading them but this time we'll use functions instead of the timeline to perform these actions// create our get next movie function
function getNextMovie(){
// attach our next movieclip from the stage using our array
attachMovie(mcs[count] + "_done.swf", "bg2", _root.getNextHighestDepth());
// begin playing its timeline
bg2.gotoAndPlay(2);
// create a delay before unloading and loading
var si = setInterval(function() { // refrence our delay with variable si
clearInterval(si); // when delay is over clear variable si
bg2.removeMovieClip(); // remove the current movieclip
count++; // increase our count variable by 1
getNextMovie(); // call our function and do this all over again
}, 5000); // set our delay for 5 seconds
}let me know what you think and what you don't understand
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.