[RESOLVED] Truncate Text in Dynamic Text Field?
Hello All,
I have a Dynamic Text Field placed on stage at authortime.
I need to truncate the text within that field by replacing the last VISIBLE word with an ellipse.
Now, the problem I'm encountering is that in a multiline text box with wrapping turned on, I can't figure out a way to get the index of the last visible character, or some other point where I can start truncating.
Part of the issue is that if you pass a really long SINGLE line string into the text field, Flash will wrap it like you would expect, however, the text gets masked if the text field isn't big enough to display it all, but the text that ISN'T visible still is factored into the values returned by AS3.0
For example, let's say the text field is only big enough to display 3 lines of text.
If the long string I'm trying to display has to wrap 17 times, then myTextField.numLines would return 17 because the unseen text still exists... it's just not able to be displayed in the text field.
Also, myTextField.bottomScrollV doesn't help because the string is all 1 line, so even though you can't see the ENTIRE line, it still returns as visible.
So, does anyone know how to figure out which is the last visible character in a text box?
Everything I've seen about truncating text involves coming up with some arbitrary max character amount, and just truncating at that point.
I would prefer to figure it out dynamically based on the text field's width and height because:
1) character sizes/widths differ for every font, and
2) There may actually be several different fonts used in the same text field.
Thanks!