# Assigning text in dynamically created text fields; Flash 8

**URL:** <https://forum.kirupa.com/t/assigning-text-in-dynamically-created-text-fields-flash-8/208717>\
**Category:** flash\
**Created:** [December 1, 2006, 4:06pm UTC](https://forum.kirupa.com/t/assigning-text-in-dynamically-created-text-fields-flash-8/208717 "2006-12-01T16:06:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![graylensman](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@graylensman](https://forum.kirupa.com/u/graylensman)\
**Post date:** [December 1, 2006, 4:06pm UTC](https://forum.kirupa.com/t/assigning-text-in-dynamically-created-text-fields-flash-8/208717/1 "2006-12-01T16:06:16Z")

</div>

I’m having trouble with dynamically assigning text to a dynamically created text field.

This works:  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#808080]_//set font with TextFormat_[/COLOR]  
myFormat=[COLOR=#000000] **new** [/COLOR] [COLOR=#0000FF]TextFormat[/COLOR]COLOR=#000000[/COLOR];  
myFormat.[COLOR=#0000FF]align[/COLOR]=[COLOR=#FF0000]“left”[/COLOR];  
myFormat.[COLOR=#0000FF]color[/COLOR]=[COLOR=#FF0000]“0xFF3300”[/COLOR];  
myFormat.[COLOR=#0000FF]font[/COLOR]=[COLOR=#FF0000]“MyriadProBoldCon”[/COLOR];  
myFormat.[COLOR=#0000FF]size[/COLOR]=[COLOR=#000080]25[/COLOR];

[COLOR=#808080]_//create text field_[/COLOR]  
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]createTextField[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“timText”[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]10[/COLOR], [COLOR=#000080]10[/COLOR], [COLOR=#0000FF]Stage[/COLOR].[COLOR=#0000FF]width[/COLOR],[COLOR=#000080]40[/COLOR][COLOR=#000000])[/COLOR];  
timText.[COLOR=#0000FF]text[/COLOR]=[COLOR=#FF0000]“I declare a truce for robot juice”[/COLOR];  
timText.[COLOR=#0000FF]embedFonts[/COLOR]=[COLOR=#000000] **true** [/COLOR];  
timText.[COLOR=#0000FF]setTextFormat[/COLOR]COLOR=#000000[/COLOR];  
[/LEFT]  
[/FONT]

but this doesn’t:  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#808080]_//set font with TextFormat_[/COLOR]  
myFormat = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000FF]TextFormat[/COLOR]COLOR=#000000[/COLOR];  
myFormat.[COLOR=#0000FF]align[/COLOR] = [COLOR=#FF0000]“center”[/COLOR];  
myFormat.[COLOR=#0000FF]color[/COLOR] = [COLOR=#FF0000]“0xFF3300”[/COLOR];  
myFormat.[COLOR=#0000FF]font[/COLOR] = [COLOR=#FF0000]“MyriadProBoldCon”[/COLOR];  
myFormat.[COLOR=#0000FF]size[/COLOR] = [COLOR=#000080]25[/COLOR];  
[COLOR=#808080]_//create text field; text shows up right now_[/COLOR]  
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]createTextField[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“timText”[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]10[/COLOR], [COLOR=#0000FF]Stage[/COLOR].[COLOR=#0000FF]width[/COLOR], [COLOR=#000080]40[/COLOR][COLOR=#000000])[/COLOR];  
timText.[COLOR=#0000FF]text[/COLOR] = [COLOR=#FF0000]“I declare a truce for robot juice.”[/COLOR];  
timText.[COLOR=#0000FF]embedFonts[/COLOR] = [COLOR=#000000] **true** [/COLOR];  
timText.[COLOR=#0000FF]setTextFormat[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#808080]_//but click a button, and the text disappears and is not replaced!!!_[/COLOR]  
btn1.[COLOR=#0000FF]onRelease[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
timText.[COLOR=#0000FF]text[/COLOR]=[COLOR=#FF0000]“Breakfast is served all day in Hell!”[/COLOR]  
[COLOR=#000000]}[/COLOR];  
btn2.[COLOR=#0000FF]onRelease[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
timText.[COLOR=#0000FF]text[/COLOR]=[COLOR=#FF0000]“We prefer to be called Buccaneer-Americans.”[/COLOR]  
[COLOR=#000000]}[/COLOR];  
btn3.[COLOR=#0000FF]onRelease[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
timText.[COLOR=#0000FF]text[/COLOR]=[COLOR=#FF0000]“It’s fun to use learning for evil!”[/COLOR]  
[COLOR=#000000]}[/COLOR];  
[/LEFT]  
[/FONT]

I’ve tried setting up the TextFormat and createTextField as a function that’s called on the onRelease handler. I’ve tried dropping the whole frackin’ code in the onRelease function for each button. Neither approach works.

I’ve been digging around on the web, looking for answers, and nothing seems to solve my problem. Does anyone have any ideas?

thanks in advance!
