# Creating Text Dynamically

**URL:** <https://forum.kirupa.com/t/creating-text-dynamically/304375>\
**Category:** flash\
**Created:** [February 6, 2010, 3:05pm UTC](https://forum.kirupa.com/t/creating-text-dynamically/304375 "2010-02-06T15:05:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![goalieguy6](https://avatars.discourse-cdn.com/v4/letter/g/9f8e36/32.png) [@goalieguy6](https://forum.kirupa.com/u/goalieguy6)\
**Post date:** [February 6, 2010, 3:05pm UTC](https://forum.kirupa.com/t/creating-text-dynamically/304375/1 "2010-02-06T15:05:26Z")

</div>

I’m currently working on a project where I need to create a grid of dynamic text boxes each displaying my specified number. I won’t go into big specifics, since I can assign the values to each text box, but for some reason I’m having problems creating the grid dynamically. I’ve used the same method for attaching Movie Clips in a grid, and it works fine, so I can’t figure out for the life of me what the problem is.

Here’s the code

[AS]  
counter = 0;

for(var k=1;k\<=20;k++){  
for(var l=1;l\<=20;l++){  
counter++;

```
	text_container.createTextField("textbox"+counter);
	text_container["textbox"+counter]._x = initX - 5;
	text_container["textbox"+counter]._y = initY - 5;
	text_container["textbox"+counter].text = 'Hi'
	text_container["textbox"+counter].selectable = false;
	text_container["textbox"+counter].embedFonts = true;
	text_container["textbox"+counter].setTextFormat(_root.myformat);
	
	trace(text_container["textbox"+counter]); // Traces Undefined
	
	initX +=10;
}
initY +=10;
initX = 15;

```

}  
[/AS]

Here’s the code I’m using to attach Movie Clips, which is working fine.  
[AS]  
for(var i=1;i\<=20;i++){  
for(var j=1;j\<=20;j++){  
counter++;  
grid\_container.attachMovie(“Block”,“block”+counter,counter);  
grid\_container[“block”+counter].\_x = initX;  
grid\_container[“block”+counter].\_y = initY;  
grid\_container[“block”+counter].swatch = 15;  
grid\_container[“block”+counter].number = counter;

```
	initX +=10;
}
initY +=10;
initX = 15;

```

}  
[/AS]

Any help would be appreciated!
