Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Autosize(txt:TextField):void
- {
- //You set this according to your TextField's dimensions
- var maxTextWidth:int = 145;
- var maxTextHeight:int = 30;
- var f:TextFormat = txt.getTextFormat();
- //decrease font size until the text fits
- while (txt.textWidth > maxTextWidth || txt.textHeight > maxTextHeight) {
- f.size = int(f.size) - 1;
- txt.setTextFormat(f);
- }
- }
Add Comment
Please, Sign In to add comment