Help finding line position of character

I have a flash app that cycles through different paragraphs of a text field and selects them. To find the paragraphs I find the character position of the first and last characters within the field. What I’m wondering is if there is a way to find out what line number a particular character in a text field is on so that I can adjust the text field to automatically set a scroll position to a line with that first character. Currently as I select pargraphs in my text field, the selected text goes beyond the viewable area of the text field.

If you want an example take a page or so of text with paragraph pages and paste it into the big text frame on this page. Once you hit “commit” it will find the paragraphs and you can use Next and Prev to scroll through them. (its a very rough alpha version utility to generate XML)

Any help is appreciated!