# Set textFormat of dynamically created textField

**URL:** <https://forum.kirupa.com/t/set-textformat-of-dynamically-created-textfield/280279>\
**Category:** flash\
**Created:** [January 25, 2009, 4:36pm UTC](https://forum.kirupa.com/t/set-textformat-of-dynamically-created-textfield/280279 "2009-01-25T16:36:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dawdus](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@dawdus](https://forum.kirupa.com/u/dawdus)\
**Post date:** [January 25, 2009, 4:36pm UTC](https://forum.kirupa.com/t/set-textformat-of-dynamically-created-textfield/280279/1 "2009-01-25T16:36:18Z")

</div>

here is the code:

// Create new textFormat object-----  
var myTF:TextFormat = new TextFormat();  
myTF.font = “Verdana”;  
myTF.color = 0x333333;

// LOOP - create textfields, and name them.  
for (var i:int = 1; i\<6; i++){  
var myText:TextField = new TextField;  
myText.text = "text "+i;  
myText.x = 25;  
myText.y = 25+20\*i;  
myText.name = “t”+i;  
addChild(myText);  
trace(myText.name); //t1, t2, t3 etc.  
}

// - event listener for the button to apply textformat when clicked  
myBtn\_btn.addEventListener(MouseEvent.CLICK, changeTextStyle);  
function changeTextStyle(e:MouseEvent):void {  
t3.setTextFormat(myTF); // - access of undefined property t3;  
}

how do I address only the texField named t3 ?
