How to make a auto resize textbox/textfield in

Question by lidude56910: How to make a auto resize textbox/textfield in
i want a textbox in to auto resize by giving font size and font family and my textbox width. i wan to observe the paragraphs and word wrap!
So in load i give font-size, font-family and the text and its width (i don’t need to change the width) and it should automatically increase the height of textbox!

doesn’t matter:, c#, javascript, jquery!

Best answer:

Answer by auddrey_nw

or use the following method You should call it anytime your TextField’s content changes

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;


What do you think? Answer below!

About Admin