views:

497

answers:

2

It seems that flash.text.TextField in Flash has some built-in padding. In particular, my problem is that I need to left-align a text with some other graphical elements, and there is visible (about 3px) offset. The class flash.text.TextField (or any other related text class) does not seem to have property which could change it.

I know that it may not qualify as a strict programming question, because it’s also a problem is Flash (as in the program itself), but there is some programming involved and, honestly, Stackoveflow is the best place to ask.

Edit: The 3px I mentioned above were for a particular font size. The padding depends on the font size as well.

+1  A: 

I believe this depends on the font used. Usually there is some left sidebearing set in font metrics, and that is the offset that you see. Fix is to move the textfield a few pixels to counteract the sidebearing margin.

You can read more on font sidebrearings here.

Tehnomaag
+4  A: 

According to this page, this is a fixed 2px "gutter", so it should be enough to translate the Textfield 2 pixels to the left. You can also try to use flash.text.TextField.getLineMetrics() to get information about other paddings.

schnaader
Very cool. Thank you. For some reason I was not looking at methods; I was just looking at properties. It seems that the following works exactly as I need: text.x = -text.getLineMetrics(0).x.
Jan Zich