Revision: 19919
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 3, 2009 12:21 by Winkyboy
Initial Code
with (PATHTO.YOURTEXTFIELD_INSTANCE_NAME) { addEventListener(FocusEvent.FOCUS_IN, focusField); addEventListener(FocusEvent.FOCUS_OUT, blurField); } private function focusField(e:Event) { switch (e.currentTarget.name) { case "YOURTEXTFIELD_INSTANCE_NAME" : if(e.currentTarget.text == "YOUR DEFAULT MESSAGE") e.currentTarget.text = ""; break; } } private function blurField(e:Event) { switch (e.currentTarget.name) { case "YOURTEXTFIELD_INSTANCE_NAME" : if(e.currentTarget.text == "") e.currentTarget.text = "YOUR DEFAULT MESSAGE"; break; } }
Initial URL
Initial Description
Paste this into your AS file to add focus and blur events to your text/form fields. If your field contains YOUR DEFAULT MESSAGE when focus is brought to it, it will erase itself, to be ready for text entry. If focus is lost while the field is completely empty, the default message will return.
Initial Title
AS3 Form Field focus/blur functions
Initial Tags
form, post
Initial Language
ActionScript 3