Showing posts with label textfields. Show all posts
Showing posts with label textfields. Show all posts

Monday, 9 September 2013

Losing Focus on Textfield, AS3

I had a problem with a text field, I wanted to click on it, have something happen, and be able to continue typing straight away, but it kept losing focus after the first letter.

So I added a trace statement to find out what was happening, and then it would lose focus after it was clicked.

The reason was the trace statement was causing the whole swf to lose focus. So I am sending a trace statement in the frame, so that the initial focus is dealt with. The losing of focus doesn't occur after the first trace statement.

P.S. To set focus using action script:

stage.focus = textfield_txt;
textfield_txt.setSelection(textfield_txt.length,textfield_txt.length);

Thursday, 10 June 2010

Getting the String out of the Textfield

I had always thought, possibly due to the lack of autofill, that you couldn't do this:

trace(f.text.indexOf('h'));

but you can.

Oh well.