TextField cuts off text and just shows the first letter of the text.
Case:
The textfield is getting the text value from a previously loaded XML.
Stylesheets are applied.
Solution:
If the textField.antiAliasType is set to advanced the text field doesn't like a "non breaking space character" in the beginning. A simple search for " " at the first character to identify a problematic string doesn't necessarily work. In my case the char code of the first character was 160. To be on the save side I created a simple Regular Expression to remove every first character that is not a number or not a letter:
var checkFirstLetter:RegExp = /[^\w\d](.*)/;
text = text.replace( space, '$1');
What this expression does is search for every character at the first position that is not a letter or number.
The character set for "everything that is not" sarts with [^ followed by the types, here \w for words and \d for numbers and end with ].
Then it replaces this match with the rest. The 'rest' is marked in the RegExp by a capturing group defined by the left and right bracket. you can use these groups in replace functions with the prefix "$" and the index of the group starting at 1 (could be that you have more than one group defined).
No comments:
Post a Comment