private function selectSomeText(e:Event):void { /* Get the location of the cursor. This is the character position of the cursor in the RichEditableText control after the user clicks on it. */ var activePos:int = subHead.selectionActivePosition;

/* Get the first SpanElement in the TextFlow. */ var leaf:SpanElement = new SpanElement(); leaf = SpanElement(subHead.textFlow.getFirstLeaf());

/* Get the start and end index values for the first SpanElement. */var spanStart:int = leaf.getParagraph().parentRelativeStart; var spanEnd:int = leaf.getParagraph().parentRelativeEnd;

/* For the first SpanElement, if the cursor position falls within the SpanElement's character range, then select the entire SpanElement. */ if (activePos >= spanStart && activePos <= spanEnd) { selectSpan(spanStart, spanEnd); return; }

I found the solution. It was bugging me that leaf.getParagraph().parentRelativeStart didn't look right. This would point to the paragraph element of the leaf element. After digging further, the solution was simply to remove the reference to the paragraph element.

Started with:

/* Get the start and end index values for the first SpanElement. */var spanStart:int = leaf.getParagraph().parentRelativeStart; var spanEnd:int = leaf.getParagraph().parentRelativeEnd;

Changed to:

/* Get the start and end index values for the first SpanElement. */ var spanStart:int = leaf.parentRelativeStart; var spanEnd:int = leaf.parentRelativeEnd;