AS3窗体字段聚焦/模糊功能
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AS3窗体字段聚焦/模糊功能相关的知识,希望对你有一定的参考价值。
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.
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; } }
以上是关于AS3窗体字段聚焦/模糊功能的主要内容,如果未能解决你的问题,请参考以下文章