Skip to main content
Known Participant
Nov 24, 2009 8:48 PM UTC
Question

Get Position of Character at Selected Line Help?

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 is closed to new replies. Start a new post to keep the conversation going.

1 reply

viatroposAuthor
Known Participant
Nov 24, 2009 9:30 PM UTC

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);

}

Translate