Multi-Line text properties

I am trying to find a way to write actionscript for a function that finds the length of each individual line in a paragraph then draws a background specific to each lines length.(the last part i can handle).

What i don’t know how to do is find the length of an individual line in a paragraph.

The file below show what i want for the final result.

http://e-mergedesign.com/ORC/texthelp.html

I am hoping there is a simpler way then having to draw each by hand before runtime.

If you can point me in the right direction i would be very grateful.

Thanks everyone, greatly appreciate your time.

Sincerely,

Martha