Flash Lite 2 |
|||
| 开发 Flash Lite 2.x 应用程序 > 使用文本和字体 > 文本字段示例应用程序(仅限于 Flash Professional) | |||
本节介绍如何创建简单的应用程序,该应用程序可获取用户的文本输入,然后设置该文本的格式并使其显示在支持 HTML 的动态文本字段中。该应用程序还使用 SetFocusRectColor 命令将焦点矩形颜色由默认颜色(黄色)更改为黑色。
在位于硬盘上 Flash Professional 8 安装文件夹中的 Samples and Tutorials/Samples/Flash Lite 2.0/ 文件夹中,可以找到此示例的完整范例应用程序 textfield_example.fla。
Selection.setFocus(inputTxt);
fscommand2("SetFocusRectColor", 0, 0, 0);
inputTxt.onChanged = function() {
messageTxt.htmlText = "You entered:<i>" + this.text + "</i>";
}
Selection.setFocus() 方法将初始焦点设置到输入文本字段 (inputTxt) 上。然后,fscommand2() 函数调用指定一种自定义焦点矩形颜色。最后,输入文本字段的 onChanged 事件处理函数(只要输入文本字段的内容被更改就会调用该函数)设置用户在 messageTxt 文本字段中输入的文本的格式并显示该文本。
messageTxt 文本字段中。