# For Loop to associate an Array

**URL:** <https://forum.kirupa.com/t/for-loop-to-associate-an-array/262002>\
**Category:** flash\
**Created:** [June 2, 2008, 3:38pm UTC](https://forum.kirupa.com/t/for-loop-to-associate-an-array/262002 "2008-06-02T15:38:50Z")\
**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:** [June 2, 2008, 3:38pm UTC](https://forum.kirupa.com/t/for-loop-to-associate-an-array/262002/1 "2008-06-02T15:38:50Z")

</div>

I created an Array with captions and now I want to make it so when I press one of the buttons it will make the caption appear. For this I have used a For loop.

_thumbNailCaption_\* does trace the variables I’ve assigned, but I can’t get _thumbNailCaption_.textDisp\* to trace anything like it. No matter how many variations I’ve made, it always comes out undefined! Does anyone know what I’m doing wrong?

> stop();

// CREATES AN ARRAY TO HOLD THUMBNAIL COMMENTS  
var thumbNailCaption = new Array();  
thumbNailCaption[0] = “abc”;  
thumbNailCaption[1] = “def”;  
thumbNailCaption[2] = “ghi”;

// BUTTON PROPERTIES  
for (i = 0; i \< 12; i++) {  
\*\* this[“thumbNailCaption”+i].textDisp = thumbNailCaption\*;\*\*  
mcBody.mainBody[“thumbNail”+ i].onRelease = function() { \_root.mcBody.mainBody.textCaption.textDisp = this.textDisp;}  
}
