Posted By

shuchii on 11/29/10


Tagged

input TextField as3 hint


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

tspitzr
onemanstudio
prjohnny
kingundkong
tombarc
carface
Josueriv


Input Textfield hint


 / Published in: ActionScript 3
 

Showing an input hint in the TextField itself, hiding it on focus/input, and showing it again when the input is left empty.

  1. var hint:String = "dd-mm-yyyy";
  2. txtDate.text = hint;
  3.  
  4. txtDate.addEventListener(FocusEvent.FOCUS_IN, focusIn);
  5. txtDate.addEventListener(FocusEvent.FOCUS_OUT, focusOut);
  6.  
  7. private function focusIn(evt:FocusEvent):void
  8. {
  9. if (evt.target.text == hint) txtDate.text = "";
  10. }
  11.  
  12. private function focusOut(evt:FocusEvent):void
  13. {
  14. if (evt.target.text == "") txtDate.text = hint;
  15.  
  16. }

Report this snippet  

You need to login to post a comment.