Skip to main content
March 8, 2010
Question

Spark TextArea: Finding the Number of Lines in a Paragraph

  • March 8, 2010
  • 1 reply
  • 1733 views

Hi all,

I was redirected from the "Flash Builder and Flex SDK" forum to here. Here's my original post:

"Finding the total number of lines can be done (http://blog.flexexamples.com/2010/01/13/determining-the-number-of-lines-in-a-spa rk-richeditabletext-control-in-flex-4/), but is it possible to find the number of lines of any arbitrary paragraphs in a Spark TextArea? I've looked around and couldn't figure it out. Thanks in advance for any pointers!"

Thanks!

This topic has been closed for replies.

1 reply

Adobe Employee
March 9, 2010

Here's a simple example of something that iterates over the lines to get the size of the paragraph:

private function paragraphHeight(p:ParagraphElement):Number

{

     var height:Number = 0;

     var pos:int = p.getAbsoluteStart();

     var endPos:int = pos + p.textLength;

     while (pos < endPos)

     {

          var line:TextFlowLine = p.getTextFlow().flowComposer.findLineAtPosition(pos);

          height += line.height;

          pos += line.textLength;

     }

     return height;

}

- robin