Skip to main content
Known Participant
November 24, 2009
Question

Get Position of Character at Selected Line Help?

  • November 24, 2009
  • 1 reply
  • 347 views

How do you get the position of the first character of the line in which the anchor is on?  Something simple but I can't find the API.  I'm trying to do this on the spark.components.TextArea with a TextFlow.

Thanks!

This topic has been closed for replies.

1 reply

viatroposAuthor
Known Participant
November 24, 2009

public static function getSelectedLineBoundsPosition(editor:RichEditableText):Point

{

     var textFlow:TextFlow = editor.textFlow;

     if (!textFlow)

          return new Point();

     var flowComposer:IFlowComposer = textFlow.flowComposer;

     var line:TextFlowLine = flowComposer.findLineAtPosition(editor.selectionActivePosition);

     var start:Number = line.absoluteStart;

     var end:Number = start + line.textLength;

     return new Point(start, end);

}