這一段時間在倒騰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按鈕";
}
};
stop();
本文轉自:http://www.5uflash.com/flashjiaocheng/Flashzujianxuexi/1360.html