Size Text to Container
04.27.2010The new Text Layout Framework for Flash Player is a huge improvement over the historic TextField. Even so, it’s still not easy to have text auto-size to fit its container(s). In the demo app below I’ve implemented one solution that makes the text as large as possible without being cropped. Go head, type something in the box. Right-click the app to get to the source.
The basic methodology is very similar to the Guess the Number game where you whittle down the options until you get to the one you’re after. With a few smart guesses, this can be decently efficient (~20ms). If you can come up with a more efficient or elegant way to accomplish the same task, post a comment below!
Tags: auto-size, fit, scale, Text Layout Framework, textflow, TLF



Thank you sir!