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.
  1. with (PATHTO.YOURTEXTFIELD_INSTANCE_NAME) {
  2. addEventListener(FocusEvent.FOCUS_IN, focusField);
  3. addEventListener(FocusEvent.FOCUS_OUT, blurField);
  4. }
  5.  
  6. private function focusField(e:Event) {
  7. switch (e.currentTarget.name) {
  8. case "YOURTEXTFIELD_INSTANCE_NAME" :
  9. if(e.currentTarget.text == "YOUR DEFAULT MESSAGE") e.currentTarget.text = "";
  10. break;
  11.  
  12. }
  13. }
  14. private function blurField(e:Event) {
  15. switch (e.currentTarget.name) {
  16. case "YOURTEXTFIELD_INSTANCE_NAME" :
  17. if(e.currentTarget.text == "") e.currentTarget.text = "YOUR DEFAULT MESSAGE";
  18. break;
  19.  
  20. }
  21. }

以上是关于AS3窗体字段聚焦/模糊功能的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 AS3 Form Field焦点/模糊功能

如何使用AS3,实现百度模糊查询提示那样。

检索聚焦/模糊的文本

将货币符号切换到焦点/模糊上的窗体字段-对成本数据有用

SQL 怎么实现模糊查询?

jQuery 模糊事件在 Chrome 中触发了两次