The more amount of text there is in the dynamic textbox, the smaller the text (so it fits inside).
How do I do that?
All the scripts I find are really long. Surely there's some short method which only has one or two lines of code?
The more amount of text there is in the dynamic textbox, the smaller the text (so it fits inside).
How do I do that?
All the scripts I find are really long. Surely there's some short method which only has one or two lines of code?
At 11/27/14 12:22 PM, Aprime wrote: The more amount of text there is in the dynamic textbox, the smaller the text (so it fits inside).
How do I do that?
All the scripts I find are really long. Surely there's some short method which only has one or two lines of code?
Do a while loop and shrink the font size until the textHeight is less than or equal to the textfield height.
If you can work out some general relation between length of the text and the maximum allowed width of the text box - you can potentially omit a recursive solution.
However, aside from monospace fonts, the width and height of each character can vary enough for the general solution to break with certain strings. So you could apply the general solution first and then run a while loop to fine tune it or fix certain cases.
Thanks!
var p:TextFormat =name_txt.getTextFormat();
while (name_txt.textHeight > name_txt.height) {
p.size = int(p.size) - 1;
name_txt.setTextFormat(p);
}