/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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); } }