Posted By

sidneydekoning on 08/27/09


Tagged

selection as3 texfield setSelection


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

donaldleegraham


Set selection to a textfield


 / Published in: ActionScript 3
 

  1. // To set selection a textfield, use the following;
  2.  
  3. var _textInput1:TextField = new TextField();
  4. _textInput1.addEventListener(Event.CHANGE, handleTextChange, false, 0, true);
  5.  
  6. function handleTextChange(event:Event):void {
  7.  
  8. switch(event.target){
  9. case _textInput1:
  10. trace("input 1");
  11. if(_textInput1.text.length == 2) {
  12. stage.focus = _textInput2;
  13. _textInput2.setSelection(0, _textInput2.text.length); // or second param equals 0 -> 0,0
  14. }
  15. break;
  16. }
  17. }

Report this snippet  

You need to login to post a comment.