# \[FMX\] Measuring real pixel length of string

**URL:** <https://forum.kirupa.com/t/fmx-measuring-real-pixel-length-of-string/59230>\
**Category:** flash\
**Created:** [July 29, 2004, 2:14pm UTC](https://forum.kirupa.com/t/fmx-measuring-real-pixel-length-of-string/59230 "2004-07-29T14:14:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![borispc](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@borispc](https://forum.kirupa.com/u/borispc)\
**Post date:** [July 29, 2004, 2:14pm UTC](https://forum.kirupa.com/t/fmx-measuring-real-pixel-length-of-string/59230/1 "2004-07-29T14:14:51Z")

</div>

Hi everyone!

I’d like to know a way to measure the real length of a text string in pixels. The problem is that every character has a different width.  
The length property informs us of how many characters does the string have…but how do we measure the pixels (x space) in a precise way?

thanks!!!  
🥚

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2004, 2:19pm UTC](https://forum.kirupa.com/t/fmx-measuring-real-pixel-length-of-string/59230/2 "2004-07-29T14:19:47Z")

</div>

I would use something like:

```auto
mytext="hallo at all"
_root.createTextField("mytextfield",10,10,10,100,100)
_root.mytextfield.text=mytext
_root.mytextfield.autoSize=true
trace(_root.mytextfield._width+" : "+_root.mytextfield._height)

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2004, 4:48pm UTC](https://forum.kirupa.com/t/fmx-measuring-real-pixel-length-of-string/59230/3 "2004-07-29T16:48:51Z")

</div>

You could also use the [font=courier new]TextField.textWidth[/font] and [font=courier new]TextField.textHeight[/font] properties. These properties will return the actual width/height of the text, unlike the [font=courier new]TextField.\_width[/font] and [font=courier new]TextField.\_height[/font] properties that will return the width/height of the text field. 🙂
