# Create a dynamic object array

**URL:** <https://forum.kirupa.com/t/create-a-dynamic-object-array/297708>\
**Category:** flash\
**Created:** [October 7, 2009, 12:54pm UTC](https://forum.kirupa.com/t/create-a-dynamic-object-array/297708 "2009-10-07T12:54:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamyo](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@jamyo](https://forum.kirupa.com/u/jamyo)\
**Post date:** [October 7, 2009, 12:54pm UTC](https://forum.kirupa.com/t/create-a-dynamic-object-array/297708/1 "2009-10-07T12:54:34Z")

</div>

Hi All.

Still trying to get the hang of AS3 here. I basically have 4 MovieClips on my scene and a collection of MovieClips in the library. I want to be able to select 4 from the library at random, and display them on the stage. They will end up being clickable as its a kind of quiz where they click on the objects and the score is recorded. For now I need to get the hang of loading them at random. I also want to be able to make sure there are no duplicate buttons loaded to the stage. So far I have one movie exported to AS and displayed across the stage:

```auto
for(var i=0; i<4; i++)
{
    var appleMovie:appleMc = new appleMc();      
   
    appleMovie.x = +Math.random()*50;
    appleMovie.y = +Math.random()*50;
    
    this.addChild(appleMovie);
}

```

I did try creating an array of movie clips names and then using:

```auto
var fruit = new Array("apple", "pear", "grape", "lemon");

```

But I can’t seem to use this within the for loop. Am I on the right path with this? Your help is appreciated, cheers.
