View Full Version : How I can get the position of the last element in a textField with HTML text inside.
emanuelq
07-03-2009, 03:00 AM
Hi guys!
I have a problem. I need to get the position (x,y) of the last char in a textField with html text inside.
I try with numlines and getLineMetrics, but that only work for non-html text.
If I have a text like
<p>text one</p><p>This is the other text</p><br><br>
I need to have the position on the stage of the last "t".
any Ideas??
Thanks!
Emanuel
var charBounds:Rectangle = myTextField.getCharBoundaries(myTextField.text.len gth - 1);
// charBounds.x and charBounds.y now hold the values you're looking for.
emanuelq
07-03-2009, 06:28 PM
Hi Ev, thanks for the answer, but I tryed that to, and is the same. For the chain that I paste. return a null object.
Oh wait, those line breaks are going to create \n characters. Try this instead:
var charBounds:Rectangle = myTextField.getCharBoundaries(myTextField.text.las tIndexOf("t"));
Hi guys!
I have a problem. I need to get the position (x,y) of the last char in a textField with html text inside.
I try with numlines and getLineMetrics, but that only work for non-html text.
If I have a text like
<p>text one</p><p>This is the other text</p><br><br>
I need to have the position on the stage of the last "t".
any Ideas??
Thanks!
Emanuel
If you call textField.text instead of textField.htmlText you will get the text without the html formatting. Run you character check on the result. Make a var, say, noHtml = textField.text.
See what happens.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.