# Naming TextFields created using loop

**URL:** <https://forum.kirupa.com/t/naming-textfields-created-using-loop/318334>\
**Category:** flash\
**Created:** [January 17, 2011, 2:13pm UTC](https://forum.kirupa.com/t/naming-textfields-created-using-loop/318334 "2011-01-17T14:13:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeeto](https://avatars.discourse-cdn.com/v4/letter/z/e274bd/32.png) [@zeeto](https://forum.kirupa.com/u/zeeto)\
**Post date:** [January 17, 2011, 2:13pm UTC](https://forum.kirupa.com/t/naming-textfields-created-using-loop/318334/1 "2011-01-17T14:13:04Z")

</div>

Hi guys,

I can’t figure out what is the syntax for assigning names to textfields created dynamically using a loop.

```auto
 
for (var i:uint=0; i<10; i++) {
  var myText:TextField = new TextField();
   myText.defaultTextFormat = textFormat;
   myText.text = "some text";
   myText.x = i*20;
   addChild(myText);
}

```

As expected, this code gives me a warning “Duplicate variable definition”.  
How can I assign names dynamically (myText1, myText2, myText3…)?

Thanks
