# Textfields

**URL:** <https://forum.kirupa.com/t/textfields/186070>\
**Category:** flash\
**Created:** [April 18, 2006, 8:22pm UTC](https://forum.kirupa.com/t/textfields/186070 "2006-04-18T20:22:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ice987](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@ice987](https://forum.kirupa.com/u/ice987)\
**Post date:** [April 18, 2006, 8:22pm UTC](https://forum.kirupa.com/t/textfields/186070/1 "2006-04-18T20:22:37Z")

</div>

I am tring to create textfields on the fly that wrap the text they contain. I am using the following code but it is not working well. The text within the textfield is low and some of it is cut off.(Easy to see if I put a border around the textfield.) What’s my bext solution to create a textfield which perfectly fits the text it contains.

var caption=“someText”;

thumbTitleTextFormat=new TextFormat();  
thumbTitleTextFormat.font=“exportedArialFont”;  
thumbTitleTextFormat.align=“center”;  
thumbTitleTextFormat.size=20;  
thumbTitleTextFormat.color=0xFFFFFF;

createTextField(“thumbTitle\_txt”,13,0,0,0,0);  
thumbTitle\_txt.setNewTextFormat(thumbTitleTextFormat);  
thumbTitle\_txt.autosize=“center”;  
thumbTitle\_txt.embedFonts=true;

thumbTitle\_txt.\_width=thumbTitleTextFormat.getTextExtent(caption).width;  
thumbTitle\_txt.\_height=thumbTitleTextFormat.getTextExtent(caption).height;  
thumbTitle\_txt.text=caption;

---

<div class="post-metadata">

**Author:** ![ice987](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@ice987](https://forum.kirupa.com/u/ice987)\
**Post date:** [April 18, 2006, 8:24pm UTC](https://forum.kirupa.com/t/textfields/186070/2 "2006-04-18T20:24:19Z")

</div>

Ignore the spaces in my code. These were added when I uploaded the page

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [April 18, 2006, 11:12pm UTC](https://forum.kirupa.com/t/textfields/186070/3 "2006-04-18T23:12:47Z")

</div>

```auto
thumbTitle_txt.autosize="center";

```

:-/

isnt it

```auto
thumbTitle_txt.autosize=true;

```

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [April 18, 2006, 11:48pm UTC](https://forum.kirupa.com/t/textfields/186070/4 "2006-04-18T23:48:24Z")

</div>

> [@nathan99](#):
>
> ActionScript Code:  
> [FONT=Courier New][LEFT]thumbTitle\_txt.[COLOR=#0000ff]autosize[/COLOR]=[COLOR=#ff0000]“center”[/COLOR];  
> [/LEFT]  
> [/FONT]
> 
> :-/
> 
> isnt it
> 
> ActionScript Code:  
> [FONT=Courier New][LEFT]thumbTitle\_txt.[COLOR=#0000ff]autosize[/COLOR]=[COLOR=#000000] **true** [/COLOR];  
> [/LEFT]  
> [/FONT]

It depends on what side of the text field you want to remain static. But the “s” in _autoSize_ should be capitalized:

```auto
var caption = "someText";
thumbTitleTextFormat = new TextFormat();
thumbTitleTextFormat.font = "exportedArialFont";
thumbTitleTextFormat.align = "center";
thumbTitleTextFormat.size = 20;
thumbTitleTextFormat.color = 0xFF0000;
createTextField("thumbTitle_txt", 13, 0, 0, 0, 0);
thumbTitle_txt.setNewTextFormat(thumbTitleTextFormat);
thumbTitle_txt.autoSize = "center";
thumbTitle_txt.embedFonts = true;
thumbTitle_txt._width = thumbTitleTextFormat.getTextExtent(caption).width;
thumbTitle_txt._height = thumbTitleTextFormat.getTextExtent(caption).height;
thumbTitle_txt.text = caption;

```

:cons:
