<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="620" borderColor="#FD9706" textAlign="center" width="1072">
<mx:Panel x="10" y="10" width="560" height="372" layout="absolute"borderColor="#FADA05" backgroundColor="#CE0FF7" title="计算器" fontSize="20" fontStyle="normal" fontGridFitType="none" fontAntiAliasType="normal" themeColor="#F61414" textDecoration="none" verticalAlign="middle" fontWeight="bold">
<mx:Script>
<![CDATA[
import mx.messaging.SubscriptionInfo;
static private var a:Array=new Array();
private function button_clicked(event:Event):void
{
if(event.target.id== "button_1") { input.text+="1"; }
else if(event.target.id == "button_2")
{
input.text+="2";
}
else if(event.target.id == "button_3")
{
input.text+="3";
}
else if(event.target.id == "button_4")
{
input.text+="4";
}
else if(event.target.id == "button_5")
{
input.text+="5";
}
else if(event.target.id == "button_6")
{
input.text+="6";
}
else if(event.target.id == "button_7")
{
input.text+="7";
}
else if(event.target.id == "button_8")
{
input.text+="8";
}
else if(event.target.id == "button_9")
{
input.text+="9";
}
else if(event.target.id == "button_0")
{
input.text+="0";
}
else if(event.target.id == "button_clear")
{
input.text="";
while(a.length>0)
a.pop();
}
}
private function jisuan():void
{ /*
switch(a[a.length-2])
{
a.push(input.text);
if(a[a.length-2]=="+")
input.text=Number(a[a.length-3])+Number(a[a.length-1])+"";
else if(a[a.length-2]=="-")
input.text=Number(a[a.length-3])-Number(a [a.length-1])+"";
else if(a[a.length-2]=="×")
input.text=Number(a[a.length-3])*Number(a[a.length-1])+"";
else if(a[a.length-2]=="÷")
input.text=Number(a[a.length-3])/Number(a[a.length-1])+"";
a.push(input.text);
}
]]>
</mx:Script>
<mx:TextInput id="input" x="23" y="10" width="249" height="43" fontSize="35" backgroundColor="#A3E90D"/>
<mx:Button x="23" y="71" id="button_1" label="1" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="82" y="71" label="2" id="button_2" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="153" y="71" label="3" id="button_3" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="23" y="114" label="4" id="button_4" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="85" y="114" label="5" id="button_5" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="153" y="114" label="6" id="button_6" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="23" y="157" label="7" id="button_7" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="82" y="157" label="8" id="button_8" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="153" y="157" label="9" id="button_9" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="23" y="200" label="0" id="button_0" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="221" y="71" label="+" id="button_add" click="a.push(input.text),a.push('+'),input.text=''" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="221" y="114" label="-" id="button_sub" click="a.push(input.text),a.push('-'),input.text=''" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="221" y="157" label="×" id="button_mul" click="a.push(input.text),a.push('×'),input.text=''" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="221" y="200" label="÷" id="button_div" click="a.push(input.text),a.push('÷'),input.text=''" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="153" y="200" label="=" id="button_equal" click="jisuan()" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
<mx:Button x="82" y="200" label="C" id="button_clear" click="button_clicked(event)" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#E708FB, #F60808]" height="35" width="51" fontSize="25"/>
</mx:Panel>
</mx:Application>
效果图如下: