Flashmx2004系列教程〈二〉UI组件-Alertcompoents
更新时间:
当我们操作有误时,经常看见一些无故弹出的小窗口,我们称之为提示对话框。2004提供了一个组件用来处理提示对话框,但是有时他又是必须。比如当用户在你的文本域中输入了不合法的字符时。这时就是通知用户办输入正确的字符。那么提示对话框的设计便是格外有用的。就让我们看一下如何使用对话框组件。
1。首先让我们以范例文件开始。仍然使用我的上一次BUTTON按钮组件的例子。如果你已经关闭。可以重新找开或重新下载。
2。将Alert组件拖至场景中。你不用关心它放在哪,因为我们只要想将它放在库中。稍候我们将要将它删除。

3。删除你刚拖入场景的Alert组件。
4。那么Alert组件不在场景中,我们怎么样去使用它呢很简单,它完全是用代码控制的。编辑第一帧的代码。使之当我们单击按钮的时候出现提示框。
// 载入ALERT类
import mx.controls.Alert;
// 创建按钮组件的侦听器
myButtonListener = new Object();
// 创建侦听事件以侦听按钮的单击事件
myButtonListener.click = function ()
{
// 显示提示框
// 第一行是窗口内容。
// 第二行是标题
// 显示两个按钮,NO和CANCEL
// NO 按钮设为当前状态
Alert.show
(
"Oh no, you did something terrible.
The sky is going to fall on your head!",
"Very Bad Error",
Alert.NO | Alert.CANCEL,
_root, alertHandler,
Alert.NO
);
}// 注册侦听器
myButton.addEventListener("click", myButtonListener );// 创建alerthandler的方法用于返回点击按钮后所返回的状态
alertHandler = function ( theEvent )
{
// check which button the user pressed
if (theEvent.detail == Alert.NO)
{
// no button
trace ("No? What do you mean, \"no?\"");
}
else if (theEvent.detail == Alert.CANCEL)
{
// cancel button
trace ("Hey! Who said you could cancel?");
}
}
5。测试你的影片。
栏目精选
相关文章
中"Fl,la,as,sh,hm,mx,x2,20,00,04,4系,系列,列教,教程,程〈,〈二,二〉,〉U,UI,I组,组件,件-,-A,Al,le,er,rt,tc,co,om,mp,po,oe,en,nt"相关内容
中"Fl,la,as,sh,hm,mx,x2,20,00,04,4系,系列,列教,教程,程〈,〈二,二〉,〉U,UI,I组,组件,件-,-A,Al,le,er,rt,tc,co,om,mp,po,oe,en,nt"相关内容
中"Fl,la,as,sh,hm,mx,x2,20,00,04,4系,系列,列教,教程,程〈,〈二,二〉,〉U,UI,I组,组件,件-,-A,Al,le,er,rt,tc,co,om,mp,po,oe,en,nt"相关内容
每日推荐










