用flash as2.0做5个按钮,点击其中三个后能弹出一个对话框,且其他的两个按钮不能再点击了。这要怎么写呀?
1个回答
展开全部
var clickNum = 0; //点击次数
var alertMc; //对话框元件
alertMc.visible = false;
for(var i:int = 0;i<5;i++){
this["btn"+i].addEventListener(MouseEvent.CLICK,clickHandle);
}
function clickHandle(e:MouseEvent):void{
clickNum ++;
if(clickNum == 3){
removeListen();
alertMc.visible = true;
}
}
function removeListen():void{
for(var i:int = 0;i<5;i++){
this["btn"+i].removeEventListener(MouseEvent.CLICK,clickHandle);
}
}
var alertMc; //对话框元件
alertMc.visible = false;
for(var i:int = 0;i<5;i++){
this["btn"+i].addEventListener(MouseEvent.CLICK,clickHandle);
}
function clickHandle(e:MouseEvent):void{
clickNum ++;
if(clickNum == 3){
removeListen();
alertMc.visible = true;
}
}
function removeListen():void{
for(var i:int = 0;i<5;i++){
this["btn"+i].removeEventListener(MouseEvent.CLICK,clickHandle);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询