So I’ve got 10 MovieClips on stage that animate in, and each MC has a stop command on the first frame. I then have this AS on the main timeline on the last frame when everything is in place:
this._lockroot;
// Random MovieClip Actions
// Choose random selection of MC's
var services:Array = [copyWriting, design, eventManagement, marketingStrategy, marketResearch, mediaPlanning, projectManagement, promotionalItems, publicRelations, webInteractiveMedia];
var indexArray:Array = [];
var selectedServices:Array = new Array();
// Number of Items to Fade Out
var Faded:Number = 6;
var isFadedOut:Boolean = false;
var reset:Boolean = false;
//
function choose() {
var exists:Boolean = false;
var rand:Number = 0;
while(indexArray.length<Faded) {
rand = Math.floor(Math.random()*10);
for(i=0; i<indexArray.length; i++){
if(indexArray*==rand){
exists=true;
break;
}
}
if(!exists){
indexArray.push(rand);
}exists=false;
}
fadeOut();
trace(indexArray);
}
function fadeOut() {
for (var h = 0; h<Faded; h++) {
_root.services[indexArray[h]].gotoAndPlay(1);
trace(services[indexArray[h]]);
}
isFadedOut = true;
reset = false;
}
function fadeIn() {
for (var h = 0; h<Faded; h++) {
_root.services[indexArray[h]].gotoAndPlay(6);
}
reset = true;
}
function changeServices() {
if (isFadedOut) {
fadeIn();
if (reset) {
indexArray = new Array();
}
isFadedOut = false;
}
choose();
}
ServiceLoop = setInterval(changeServices, 3000);
I’ve got two arrays, one with the MovieClip names, and one listing indexes of the MovieClips with a random function that pulls the value of Faded(6) randomly and tells those MC’s to gotoAndPlay at frame 2 and 6 depending if they are fading out or fading in.
The problem I’m having is that in the Output panel I can see that it’s choosing 6 unique MC’s randomly every 3000ms, but on the stage, it sometimes doesn’t animate all 6 MovieClips. Sometimes it does just one, sometimes it does 3, etc. It’s frustrating, and more than likely I’m just overlooking something. Any help is appreciated =)
Oh, and the .fla if anybody is interested in helping- Thanks again!