# Randomness / Arrays / MC's not playing?

**URL:** https://forum.kirupa.com/t/randomness-arrays-mcs-not-playing/244005
**Category:** flash
**Created:** [November 13, 2007, 2:31pm UTC](https://forum.kirupa.com/t/randomness-arrays-mcs-not-playing/244005 "2007-11-13T14:31:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sw0bes](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sw0bes/32/3424_2.png) [@sw0bes](https://forum.kirupa.com/u/sw0bes)
#### Post date: [November 13, 2007, 2:31pm UTC](https://forum.kirupa.com/t/randomness-arrays-mcs-not-playing/244005/1 "2007-11-13T14:31:18Z")

</div>

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:

```auto
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!
