views:

46

answers:

3

I'm trying to programmatically select the text in a textbox, and focus on it too, so that when the form is launch the user only has to start typing and it will replace what is already there.

I've been using the code:

stage.focus = _finalScoreTF;
_finalScoreTF.setSelection(0, _finalScoreTF.text.length - 1);

but it doesn't work...any ideas?

A: 

From the Adobe Docs, maybe try using _finalScoreTF.length for the length of the textField?

Hope this helps.

Richard Inglis
nope, sorry, that didn't help.
Malfist
A: 

Your code works (but I agree with Richard, you should use length rather than length-1), but my guess is that after your code is executed, something else happens that makes _finalScoreTF lose focus again. This is often the case. The timing of when you set focus is significant.

Lars
A: 

hi You can use directly with length no need of length -1

Rajesh