Sunday, January 6, 2008

positioning the cursor in a text field

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:

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:


if we're using a TextInput component, use its built in setFocus method:


1 comment:

Douglas Mills said...

Hey Craig -- thank you for this. I just spent hours beating my head against a wall trying to figure this out. I kept getting close but could not quite get it to work. And of course nowhere finding documentation for AS2 CS4...