# Dynamically adding instance names

**URL:** <https://forum.kirupa.com/t/dynamically-adding-instance-names/320744>\
**Category:** flash\
**Created:** [March 31, 2011, 8:52pm UTC](https://forum.kirupa.com/t/dynamically-adding-instance-names/320744 "2011-03-31T20:52:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fs\_tigre](https://avatars.discourse-cdn.com/v4/letter/f/edb3f5/32.png) [@fs\_tigre](https://forum.kirupa.com/u/fs_tigre)\
**Post date:** [March 31, 2011, 8:52pm UTC](https://forum.kirupa.com/t/dynamically-adding-instance-names/320744/1 "2011-03-31T20:52:08Z")

</div>

Hi,

Is it possible to add a textField dynamically but have different instance name each time this is created? In other words if I have a button that whenever its click it will add a textField to the stage and assigns a new instance each time this is added.

```auto
button.addEventListener(MouseEvent.CLICK, addField);
   
  var inputWidth = 200;
  var inputHeight = 20;
   
  function addField(event:MouseEvent):void{
   
    var textFieldName:TextField = new TextField();
    textFieldName.type = TextFieldType.INPUT;
    textFieldName.border = true;
    textFieldName.width = inputWidth;
    textFieldName.width = inputHeight;
    textFieldName.x = Math.random()* 500;
    textFieldName.y = Math.random()* 500;
    textFieldName.multiline = true;
    textFieldName.wordWrap = true;
    addChild(textFieldName);
   
  }

```

Something like this but instead of textFieldName this would be different each time.

Thanks a lot!
