positioning the cursor in flash can be a little tricky and sometimes temperamental, but we should be able to control where the cursor is with setSelection, with both beginIndex and endIndex set to the same position, for example the end of the input box:
testBox.setSelection(testBox.text.length,testBox.text.length);
We may also need to first set the focus to the text box, if the focus may be elsewhere. If our ‘text input’ is a TextField of type ‘input text’, then set focus through the stage object:
stage.focus=testBox;
testBox.setSelection(testBox.text.length,testBox.text.length);
if we’re using a TextInput component, use its built in setFocus method:
testBox.setFocus();
testBox.setSelection(testBox.text.length,testBox.text.length);
Leave a Reply