|
var arr_sf:Array=["+","-","*","/"];
sr1_txt.restrict="0-9";
sr2_txt.restrict="0-9";
//xs_txt.visible=false
bk.htmlText="<a href=\'http://1hujinjin1.blog.163.com\'>博客:http://1hujinjin1.blog.163.com/</a>"
for (var i:int=1; i<arr_sf.length+1; i++) {
this["btn"+i]._txt.text=arr_sf[i-1];
this["btn" + i].addEventListener(MouseEvent.CLICK,sf);
}
function sf(event:Event) {
if (sr1_txt.text=="" || sr2_txt.text=="" ) {
pd_jg.text="数字1和数字2都不能为空";
} else {
switch (event.target.text) {
case "+" :
pd_jg.text="计算结果:"+(int(sr1_txt.text)+int(sr2_txt.text)).toString();
// xs_txt.text=(int(sr1_txt.text)+int(sr2_txt.text)).toString();
break;
case "-" :
pd_jg.text="计算结果:"+(int(sr1_txt.text)-int(sr2_txt.text)).toString();
break;
case "*" :
pd_jg.text="计算结果:"+(int(sr1_txt.text)*int(sr2_txt.text)).toString();
break;
case "/" :
pd_jg.text="计算结果:"+(int(sr1_txt.text)/int(sr2_txt.text)).toString();
break;
}
}
}
本文由胡金金个人网站整理发布,转载请注明地址:http://www.hujinjin.com/info/102.html