# Convert string to instance name

**URL:** <https://forum.kirupa.com/t/convert-string-to-instance-name/297853>\
**Category:** flash\
**Created:** [October 9, 2009, 8:59am UTC](https://forum.kirupa.com/t/convert-string-to-instance-name/297853 "2009-10-09T08:59:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drkb](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@drkb](https://forum.kirupa.com/u/drkb)\
**Post date:** [October 9, 2009, 8:59am UTC](https://forum.kirupa.com/t/convert-string-to-instance-name/297853/1 "2009-10-09T08:59:59Z")

</div>

Hi. I don’t have a lot of AS3 experience and could really do with some help.

I have a Flash poetry project in which I have 49 separate dynamic text boxes on stage. Each has a separate instance name - “cell\_1”, “cell\_2”, “cell\_3” etc. I use the following code to store instance names in an array -

var j:int;  
for (j = 1; j \< 50; j++) {  
instances.push(“cell\_”+j)  
trace(instances[j]);  
}

What I’m trying to do is use a loop in which a single random number is generated, converted to an ASCII character and then displayed in successive text boxes. So basically there’ll be a random letter in each box. Here is the code for that.

for (var i:int; i \< 50; i++) {  
var rnd:Number = Math.round(Math.random()\*25)+65;  
var str="";  
str += String.fromCharCode(rnd);  
cell\_1.text = str;

The problem I have is that I want to be able to index the “instances” array to get the instance name and then use it in the “cell\_1.text = str” part of the loop rather than have to do the process 49 separate times. So it’ll be something like “instances\*.text = str”. I just can’t figure out how to do it and would appreciate any help from more experience programmers.

Thanks,

David
