# Calling Array items in a FOR Loop

**URL:** <https://forum.kirupa.com/t/calling-array-items-in-a-for-loop/180063>\
**Category:** Uncategorized\
**Created:** [February 25, 2006, 3:53am UTC](https://forum.kirupa.com/t/calling-array-items-in-a-for-loop/180063 "2006-02-25T03:53:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soig](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Soig](https://forum.kirupa.com/u/Soig)\
**Post date:** [February 25, 2006, 3:53am UTC](https://forum.kirupa.com/t/calling-array-items-in-a-for-loop/180063/1 "2006-02-25T03:53:15Z")

</div>

I posted this auciton earlier but I got two incorrect responses and from there no one else helps. So here we go again.

I have a for loop that runs 1 - 8. I need to call 8 items from an array. I have the for loop set up and the Array as well but they don’t work together. **To be clear, I know this _can_ be done. Please do not reply to the post if your answer is that it can not.** Now that I got that out of the way, thanks for your time.

> 

```
		 				     //Creates array to hold Body content

```

var bodies = new Array();  
bodies[0] = “”;  
bodies[1] = “Glit body”;  
bodies[2] = “Scar body”;  
bodies[3] = “Lab body”;  
bodies[4] = “Box body”;  
bodies[5] = “Snap body”;  
bodies[6] = “DHI body”;  
bodies[7] = “Max body”;

//DECLARE BUTTON PROPERTIES  
for(i=0;i\<8;i++) {  
\_root.field[“cell”+i].onPress = function () { this.gotoAndPlay(“down”);}  
\_root.field[“cell”+i].onRelease = function () { this.gotoAndPlay(“over”);  
[COLOR=Red]\*\* \_root.field.captionBodyDisp = bodies\*;}\<– this does not work. it results in undefined because it looks for the last possible number in the array and stays there. \*\*[/COLOR]  
\_root.field[“cell”+i].onRollOver = function () { this.gotoAndPlay(“over”);}  
\_root.field[“cell”+i].onRollOut = function () { this.gotoAndPlay(“up”);}  
\_root.field[“cell”+i].onDragOut = function () { this.gotoAndPlay(“up”);}  
}
