为flash Alert组件加上响应功能

 这一段时间在倒腾flex,很少玩flash了,今天翻到有人发表>,原文:
[url=http://space.flash8.net/bbs/thread-309057-1-3.html]
[color="#800080"]http://space.flash8.net/bbs/thread-309057-1-3.html[/color]
[/url]
看到后面的Alert组件只有show一下,事实上他还有响应部分,比如,用户点了确定按钮之后又该如何呢?这里就针对这个我添加一下,画蛇添足一下!我可以先下载那个alert.fla,我是在这个基础上添加的!后面我也提供了一个修改后的附件!好了,正题:
[1b]第一步[/1b]:添加个Label,和一个Button命名:Label :  MsgBox_lbl    Button : CallAlert_btn
[1b]第二步[/1b]:添加CallAlert_btn按钮代码:
CallAlert_btn.onRelease = function(){
_global.style.modalTransparency = 40;  //设定全局透明度
Alert.yesLabel = "Yes";  //Alert确定按钮文字,事实上也可以是:"确定","OK","行,就这样",一类的
Alert.noLabel = "No";
Alert.buttonWidth = 75; //如果是 "行,就这样" 那么铵钮是不是要大一点呢
Alert.show ("点击一下", "", Alert.YES | Alert.NO, _root, alClicar, "prueba", Alert.OK);
//这里是用 alClicar 对象来响应的
};
[1b]第三步[/1b]:添加响应对象
alClicar = new Object ();
alClicar = function (evento)
{
if (evento.detail == Alert.YES) //用户点了yes按钮
{
  MsgBox_lbl.text = "你点击了OK按钮";
  // 这里也可以添加一些其它的动作..

else if (evento.detail == Alert.NO) //用户点了No按钮
{
  MsgBox_lbl.text = "你点击了No按钮";
  // 这里也可以添加一些其它的动作..
}
};
以上就可以实现响应了!
[1b][/1b]
[1b]最后完整的代码应该是这样的:[/1b]
blog:
[url=http://www.oiasoft.com/blog/]http://www.oiasoft.com/blog/[/url]
web:
[url=http://www.celesteteam.com/]http://www.celesteteam.com/[/url]
[img]/Files/BeyondPic/2007-1/9/20071815716702.gif[/img]
[url=http://space.flash8.net/bbs/member.php?action=credits&view=getattach]附件[/url]
:
[url=http://space.flash8.net/bbs/attachment.php?aid=315811]alert.rar[/url]

import mx.controls.Alert
CallAlert_btn.onRelease = function(){
_global.style.modalTransparency = 40;
Alert.yesLabel = "Yes";
Alert.noLabel = "No";
Alert.buttonWidth = 75;
Alert.show ("点击一下", "", Alert.YES | Alert.NO, _root, alClicar, "prueba", Alert.OK);
};
//
alClicar = new Object ();
alClicar = function (evento)
{
if (evento.detail == Alert.YES)
{
  MsgBox_lbl.text = "你点击了OK按钮";

else if (evento.detail == Alert.NO)
{
  MsgBox_lbl.text = "你点击了No按钮";
}
};
/*
var lObj:Object = new Object();//创建侦听器对象
Alert.show("表单填写不正确,请重新填写", "",Alert.OK | Alert.CANCEL, this, lObj);
*/
stop(); 
本文转自:http://www.5uflash.com/flashjiaocheng/Flashzujianxuexi/1360.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值