# Using an Array to load MovieClips for inventory

**URL:** <https://forum.kirupa.com/t/using-an-array-to-load-movieclips-for-inventory/330515>\
**Category:** flash\
**Created:** [February 2, 2013, 8:31am UTC](https://forum.kirupa.com/t/using-an-array-to-load-movieclips-for-inventory/330515 "2013-02-02T08:31:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Logimus](https://avatars.discourse-cdn.com/v4/letter/l/65b543/32.png) [@Logimus](https://forum.kirupa.com/u/Logimus)\
**Post date:** [February 2, 2013, 8:31am UTC](https://forum.kirupa.com/t/using-an-array-to-load-movieclips-for-inventory/330515/1 "2013-02-02T08:31:38Z")

</div>

Hi all, I have what seems to be a pretty simple request but I can’t for the life of me figure out a solution. I have a feeling it’s so simple and that I must be missing something.

What I have is this:

[LIST]  
[_]An array that contains 10 items.  
[_]I also have 10 movie clips on the stage (they are simple squares, each representing an empty item slot of the player’s inventory).  
[\*]I also have 10 different movie clips in the library (these are the items that will fit inside the empty inventory slots).  
[/LIST]

What I need to do (I’m assuming) is to create a loop statement that does this for each item in the array:

[LIST=1]  
[_]Get the position of the item in the array (this is easy, just use a simple count).  
[_]Get the name of the item in the array (again, easy). Here’s where I’m struggling:  
[\*]Attach the movieClip of the same name (the “item” from the library) inside the appropriate movieClip on the stage based on the position of the item (the empty item slot).  
[/LIST]

So for example, the first item in the array will be placed in slot “1” of the player’s inventory.

Thoughts? Is there a better way to do this?

Thanks so much to anyone who looks into this!
