Skip to main content
Inspiring
March 2, 2012
Question

Detecting Text over-run in TLFTextField

  • March 2, 2012
  • 1 reply
  • 1006 views

Hi Everyone,

CS5 AS3 - TLFTextField are in use and a requirement.

I have text fields that are dynamically changed by XML for different languages.

I control the fonts (Embedded, but can vary by project builds).

Characters are not mono-spaced.

I need to detect if the inserted text exceeds the fixed text's area. I only want to want fully displayed characters.

I do not want to use the  'length' method that just counts the characters in the text string.

Does any one know of a good tutorial or have some snippets they would like to throw out for the forum?

I am building in some self test for all the fields used in a 30 language users CD with captioned movies and GUI screens.

Thanks,

Jim Wiley

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
March 2, 2012

If you look thru all of the properties of the TLFTextField class you will probably find some useful parameters.  There is one called textHeight that gives you the height of the text block in the textfield.  You could probably compare that to the hieght of the textfield itself to determine if the text exceeds the textfield size.

Jim WileyAuthor
Inspiring
March 3, 2012

Hi Again,

When I trace:

     getCharBoundaries(19)

I get data back in this form:

     (x=318.5, y=3.95, w=16.66015625, h=18.759765625)

I want to make a function that I can input like this:

testForLastDisplayedCharacter(TLFTextField.length,getCharBoundaries(i);  //where i incremetes through a for loop and first parm is the max character

will AS3 support filling in the variables of functions or has this variation been removed from the lang syntax?

do you use the "

...rest     syntax     ???

Thanks,

Jim

Ned Murphy
Legend
March 3, 2012

Your question is not clear to me.

I don't use anything known as the " ...rest syntax ???