you can use an Interval to start a function repeatedly over time, and set your MCs that you want to laod into an array. something like this: stop(); var holder = this.createEmptyMovieClip('holder', 0); var array = ['clipA_mc', 'clipB_mc', 'clipC_mc', ... , 'clipZ_mc']; var count = 0; var timer = setInverval(addMC, 5000); //five seconds delay function addMC() { if(count<array.length) { holder.attachMovie(array[count], array[count], count); }else{ clearInterval(timer); } }
I am able to get this to load the MC but it seems to load them all at the same delayed time what am I doing wrong. I would like to stager each of the MC's out over the selected times.
well, let's see, you could stop and then restart the interval with a new 'time' variable on each attachment. You could either calculate the next time, or select the next value or pick one randomly from an array, or however you would like. So you could let's say you want to just pick a random time greater than two seconds and less than five, you could do something like this: stop(); var holder = this.createEmptyMovieClip('holder', 0); var array = ['clipA_mc', 'clipB_mc', 'clipC_mc', ... , 'clipZ_mc']; var count = 0; function done() { clearInterval(timer); addMC(); delay = 2000 + Math.round(Math.random()*3000); timer = setInterval(done, delay); } //start the delay function done(); function addMC() { if(count<array.length-1) { count++; }else{ count=0; } holder.attachMovie(array[count], array[count], count); }
Don't see what you're looking for? Try a search.
|