Size Text to Container

The 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.

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!

View Demo (type something in the white box that is shown)

Fork Project

Like what you read? Give Aaron Hardy a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.