0

Is there a method that I can use to select a FlowElement? I checked a few classes including SelectionManager and EditManager and did not see anything.

ketan
  • 19,129
  • 42
  • 60
  • 98
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231

1 Answers1

0

The following example shows how to select an element:

<fx:Script>
    <![CDATA[
        import flashx.textLayout.edit.ISelectionManager;
        import flashx.textLayout.edit.SelectionState;
        import flashx.textLayout.elements.FlowElement;
        import flashx.textLayout.elements.TextFlow; 

        protected function selectElementHandler(event:MouseEvent):void {
            var selectionManager:ISelectionManager = activeFlow.interactionManager as ISelectionManager;
            var element:FlowElement = activeFlow.findLeaf(selectionManager.anchorPosition);
            selectElement(element);
        }

        public function selectElement(flowElement:FlowElement):void { 
            var textFlow:TextFlow = flowElement.getTextFlow();
            var selection:SelectionState = ISelectionManager(textFlow.interactionManager).getSelectionState();
            var startIndex:int = flowElement.getAbsoluteStart();
            selection.updateRange(startIndex, startIndex + flowElement.textLength);
            IEditManager(textFlow.interactionManager).setSelectionState(selection);
            textFlow.flowComposer.updateAllControllers();
        }
    ]]>
</fx:Script>

<s:Button label="Select current element" click="selectElementHandler(event)"/>
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231