flex 按钮的调用
publicstaticvarinstance:CheckButtonPanel;publicvarcheckButtons:Array=[];publicvardna:...
public static var instance:CheckButtonPanel;
public var checkButtons:Array=[];
public var dna:Object;
public var decidePlayers:Boolean=true;
public var players:Array=[];
public var startBtn:CheckButton=new CheckButton();
public function CheckButtonPanel()
{
instance=this;
for(var i:int=0;i<6;i++)
{
var btn:DisplayObject=DiceDemo.instance.btns[i];
//checkButtons.push(btn);
// var btnx:Number=btn.x;
// var btny:Number=btn.y;
//this.addChild(btn);
//btn.x=btnx;
//btn.y=btny;
}
var checkbutton:CheckButton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[0])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(1);
checkbutton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[1])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(2);
checkbutton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[2])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(3);
checkbutton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[3])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(4);
checkbutton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[4])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(5);
checkbutton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[5])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(6);
startBtn.data=new BtnModel("玩家选好id后\n开始游戏");
this.addChild(startBtn);
layout(checkButtons);
listen();
}
我想去调用checkButtons 和 startBtn 按钮如何去调用
调用checkButton和 startBtn 按钮如何去调用 展开
public var checkButtons:Array=[];
public var dna:Object;
public var decidePlayers:Boolean=true;
public var players:Array=[];
public var startBtn:CheckButton=new CheckButton();
public function CheckButtonPanel()
{
instance=this;
for(var i:int=0;i<6;i++)
{
var btn:DisplayObject=DiceDemo.instance.btns[i];
//checkButtons.push(btn);
// var btnx:Number=btn.x;
// var btny:Number=btn.y;
//this.addChild(btn);
//btn.x=btnx;
//btn.y=btny;
}
var checkbutton:CheckButton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[0])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(1);
checkbutton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[1])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(2);
checkbutton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[2])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(3);
checkbutton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[3])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(4);
checkbutton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[4])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(5);
checkbutton=new CheckButton();
checkbutton.setBg(DiceDemo.instance.btns[5])
this.addChild(checkbutton);
checkButtons.push(checkbutton);
checkbutton.data=new BtnModel(6);
startBtn.data=new BtnModel("玩家选好id后\n开始游戏");
this.addChild(startBtn);
layout(checkButtons);
listen();
}
我想去调用checkButtons 和 startBtn 按钮如何去调用
调用checkButton和 startBtn 按钮如何去调用 展开
1个回答
展开全部
if(checkButtons[0]!=null){(checkButtons[0] as CheckButton).dosome}不就行了
你还希望如何个调用法?
如果你想直接用鼠标单击,可以增加鼠标单击事件监听:
checkButton.addEventListener(MouseEvent.CLICK,dosome(event));
或checkButton.addEventListener(MouseEvent.CLICK,function(event){doSome(event,otherargs...)});
然后自定义dosome方法。
你还希望如何个调用法?
如果你想直接用鼠标单击,可以增加鼠标单击事件监听:
checkButton.addEventListener(MouseEvent.CLICK,dosome(event));
或checkButton.addEventListener(MouseEvent.CLICK,function(event){doSome(event,otherargs...)});
然后自定义dosome方法。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询