# Array.problem

**URL:** <https://forum.kirupa.com/t/array-problem/113966>\
**Category:** Uncategorized\
**Created:** [June 23, 2004, 1:04pm UTC](https://forum.kirupa.com/t/array-problem/113966 "2004-06-23T13:04:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![monkeyboy](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@monkeyboy](https://forum.kirupa.com/u/monkeyboy)\
**Post date:** [June 23, 2004, 1:04pm UTC](https://forum.kirupa.com/t/array-problem/113966/1 "2004-06-23T13:04:02Z")

</div>

Hi,

```
I am having problems with loading a range of movieClips into an itemQueue_mc

 I have 7 mc's with
linkage id's in the library

Once a random clip has been attached and run it's cause, the clip gets
removed from the array when the attachRandom function is triggered again.

The attachRandom function does all of this.

The problem is that not all of the clips are getting loaded in when the
attachRandom function gets called, sometimes it stops after 3, sometimes it
won't load any.

I may be missing something real obvious.

Can anyone help me with this. I can send the .fla with an exhaustive
explanation on how the clips work.

Thanks

[AS]
 //create array to store references to the clip id's
categories = new Array();.

```

categories[0] = [‘accessories\_mc’];  
categories[1] = [‘work\_mc’];  
categories[2] = [‘holiday\_mc’];  
categories[3] = [‘gym\_mc’];  
categories[4] = [‘partyTime\_mc’];  
categories[5] = [‘partyWear\_mc’];  
categories[6] = [‘comfyCasual\_mc’];

//attachRandom() function that attaches clips to the itemQueue\_mc  
function attachRandom(){  
var catLength = categories.length;  
if(catLength == 0){  
\_root.gotoAndPlay(“endGame”);  
doSomeStuff;

```
       }else{
               // let's make a random selection of the category:
                var cat = Math.round(Math.random()*(catLength-1));

```

// attach this item to the queue\_mc. by loading always into the same //depth (1), the item which was there previously gets obliterated  
\_root.itemQueue\_mc.attachMovie(categories[cat],‘curItem’,1);

```
               //as every category should only appear once, let's remove this category
               //from the array:
                categories.splice(cat,1);
       }

```

}  
[/AS]
