Vertical-alignment for TextFields – ActionScript 3.0

Vertical-alignment for textfields in ActionScript 3.0 is useful for aligning textfields to images, other UI elements in a flash app, and more! As many of you may know, Adobe introduced TLF Text along with Flash Player 10. If you are working with general consumer projects, however, chances are you are targeting Flash Player 9 as a minimum.
Before TLF TextFields, there was no direct way to vertically align TextFields.

That being said, you can easily accomplish this by using the TextLineMetrics object, or more directly, TextField‘s getLineMetrics().

TextLineMetrics allows us to access basic values for any typeface, such as ascent, descent, leading, width and height. Using ascent, we can determine a TextField’s baseline Y position.

Continue reading Vertical-alignment for TextFields – ActionScript 3.0