PDA

View Full Version : Query: How to find the x,y co-ordinates of a text in a textfield


hari-kj
06-21-2005, 05:25 AM
Hi,

I'm not sure whether this is possible.. but here goes..
I have a dynamic textfield (it has to be dynamic or input) with some text.
Now is there any possible way to find out the x,y coordinates of a particular character in the textfield.

This is really bothering me a lot in my current work.

Any help is ok :)

Navarone
06-21-2005, 12:47 PM
If the text field has an instance name, you should be able to find the x,y by using ._x and ._y properties. Lets say the text field's instance name is "my_txt"

trace(my_txt._x)//in pixels
trace(my_txt._y)//in pixels

Ruben
06-21-2005, 01:43 PM
Erm Navarone, hari-kj said:Now is there any possible way to find out the x,y coordinates of a particular character in the textfield.That being said, there's no quick and easy way to find out a character's position inside a textfield.
You could go about writing some function that would guess using textWidth (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary775.html) and textHeight (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary774.html), but I highly doubt whether that'd be precise enough (since in multilined textfields the last character isn't always exactly at the end of the line..).

:) - Ruben