answersLogoWhite

0

here is the code for simple calculator in flex,




[Bindable] private var _txt:Object;
[Bindable] private var _choos:String;

private function satu():void{
txtLayar.text = txtLayar.text + '1';
}
private function dot():void{
txtLayar.text = txtLayar.text + '.';
}
private function dua():void{
txtLayar.text = txtLayar.text + '2';
}
private function tiga():void{
txtLayar.text = txtLayar.text + '3';
}
private function empat():void{
txtLayar.text = txtLayar.text + '4';
}
private function lima():void{
txtLayar.text = txtLayar.text + '5';
}
private function enam():void{
txtLayar.text = txtLayar.text + '6';
}
private function tujuh():void{
txtLayar.text = txtLayar.text + '7';
}
private function lapan():void{
txtLayar.text = txtLayar.text + '8';
}
private function sembilan():void{
txtLayar.text = txtLayar.text + '9';
}
private function noll():void{
txtLayar.text = txtLayar.text + '0';
}
private function clear():void{
txtLayar.text = '';
}
private function sum():void{
_txt = txtLayar.text;
_choos = '1';
txtLayar.text = '';
}
private function sub():void{
_txt = txtLayar.text;
_choos = '2';
txtLayar.text = '';
}
private function mul():void{
_txt = txtLayar.text;
_choos = '3';
txtLayar.text = '';
}
private function div():void{
_txt = txtLayar.text;
_choos = '4';
txtLayar.text = '';
}
private function hasil():void{
var txt2:Number = Number(txtLayar.text);
var txt3:Number = Number(_txt);
var has:Number;
if(_choos=='1'){
has = txt3 + txt2;
}else if(_choos == '2'){
has = txt3 - txt2;
}else if(_choos == '3'){
has = txt3 * txt2;
}else if(_choos == '4'){
has = txt3 / txt2;
}
txtLayar.text = has.toString();
}
]]>








































User Avatar

Wiki User

14y ago

What else can I help you with?