This content has been marked as final. Show 4 replies
The textField property of text objects has a getCharBoundaries method. This returns a Rectangle object describing the coordinates of any nth character in the text.
I used this to draw rectangles that cover particular words in a textArea. By getting the rectangle of the first and last charcters of the word, I could calculate the needed coordinates from that. The main statements were of this form:
var myRect1:Rectangle = myTextArea.textField.getCharBoundaries(n);
where n is the character index.
I'm pretty new to Flex, and don't know yet if there is another way to achieve this. If there is, I'd love to hear.
I believe textarea has a protected getTextField() method (or something named like that) so you have to override the TextArea.
Thanks to both of you - I was successful in using the textField property and my autocomplete dropdown now works a charm.
you might need to be careful, i've been working on a spell checker for Text areas and the calculations for some coordinates are off if you use different font sizes (probably different fonts as well).