I’m building text balloons to display variable length messages in Flash. My question is pretty simple, though the answer may not be.
I have:
- The string I want to display.
- The font information.
- The width/height ratio I want the text field to have.
How do I calculate the width and height of the text field it needs to display the text I give it, nothing more, nothing less?
Easiest thing I can think off is creating a textfield, setting the custom font and text then getting the size:
e.g.
textWidth and textHeight should give you the right numbers, as opposed the width and height properties. If you need more details than this, have a look at the TextLineMetrics class.
HTH,
George