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:


iOS development with Swift - book: https://manning.com/books/ios-development-with-swift video course: https://www.manning.com/livevideo/ios-development-with-swift-lv

Tagged with: ,
Posted in Flash
One comment on “positioning the cursor in a text field
  1. 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…

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: