Calculadora En Flex -by FreeJeffSoft

17 views
Skip to first unread message

Free.Jeffrey

unread,
Mar 15, 2011, 9:42:19 PM3/15/11
to ELIPSIS
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" width="259" height="277">
<mx:Script>

<![CDATA[
//By JeffSoft
import flash.system.fscommand;
import mx.controls.Alert;
private var resp:int=0;
private var valor1:Number=0;
private var valor2:Number=0;
private var operacion:int; // var tipo puntero
private var total:int

// Botones para Numeros
public function unomuestra():void
{ num_txt.text+= String(1);}
public function dosmuestra():void
{ num_txt.text+= String(2); }
public function tresmuestra():void
{ num_txt.text+= String(3); }
public function cuatromuestra():void
{ num_txt.text+= String(4); }
public function cincomuestra():void
{ num_txt.text+= String(5);}
public function seismuestra():void
{ num_txt.text+= String(6); }
public function sietemuestra():void
{ num_txt.text+= String(7); }
public function ochomuestra():void
{ num_txt.text+= String(8); }
public function nuevemuestra():void
{ num_txt.text+= String(9);}
public function ceromuestra():void
{ num_txt.text+= String(0);}

// boton borar
public function borrar2():void{
num_txt.setFocus();
num_txt.text="";
}
//boton suma
public function sumaropera():void{
valor1 = int(num_txt.text);
num_txt.text="";
operacion=0;
}
//boton Resta
public function restar():void{
valor1 = int(num_txt.text);
num_txt.text="";
operacion=1;
}
//boton Multiplicacion
public function multiplicaropera():void{
valor1 = int(num_txt.text);
num_txt.text="";
operacion=2;
}
//boton Dividir
public function dividiropera():void{
valor1 = int(num_txt.text);
num_txt.text="";
operacion=3;
}
// calcular Raiz
public function calraiz():void{
valor1 = int(num_txt.text);
num_txt.text="";
var r:Number;
r= Math.sqrt(valor1);
num_txt.text =String(r);
}
//boton Igual
public function btnigual1():void{
valor2 = int(num_txt.text);
if (operacion == 0)
{total = valor1 + valor2;}
else if (operacion == 1)
{total = valor1 - valor2}
else if (operacion == 2)
{total = valor1 * valor2;}
else if (operacion == 3)
{total = valor1 / valor2;}
num_txt.text="";
num_txt.text =String(total);
}
//salir
public function salir2():void{
fscommand("quit");
}

// proyecto para descargar ------>
http://www.4shared.com/file/dXOKm2fB/Calc_flex.html
// en la carpeta bin-debug esta el swf
]]>
</mx:Script>
<mx:TextInput x="38" y="46" id="num_txt" width="188"/>
<mx:Button x="38" y="72" label="1" id="uno" click="unomuestra()"/>
<mx:Button x="86" y="72" label="2" id="dos" click="dosmuestra()"/>
<mx:Button x="138" y="72" label="3" id="tres" click="tresmuestra()"/>
<mx:Button x="38" y="102" label="4" id="cuatro"
click="cuatromuestra()"/>
<mx:Button x="86" y="102" label="5" id="cinco" click="cincomuestra()"/
>
<mx:Button x="138" y="102" label="6" id="seis" click="seismuestra()"/
>
<mx:Button x="38" y="132" label="7" id="siete" click="sietemuestra()"/
>
<mx:Button x="86" y="132" label="8" id="ocho" click="ochomuestra()"/>
<mx:Button x="138" y="132" label="9" id="nueve"
click="nuevemuestra()"/>
<mx:Button x="86" y="162" label="0" id="cero" click="ceromuestra()"/>
<mx:Button x="186" y="72" label="+" id="suma" click="sumaropera()"/>
<mx:Button x="186" y="102" label="-" id="resta" click="restar()"/>
<mx:Button x="186" y="132" label="*" id="multiplicar"
click="multiplicaropera()"/>
<mx:Button x="186" y="162" label="/" id="dividir"
click="dividiropera()"/>
<mx:Button x="38" y="162" label="C" id="borrar" click="borrar2()"/>
<mx:Button x="186" y="218" label="..." id="salir" click="salir2()"/>
<mx:Button x="186" y="188" label="=" click="btnigual1()" id="igual"/>
<mx:Label x="101" y="249" text="JeffSoft"/>
<mx:Button x="138" y="162" width="40" id="raiz" click="calraiz()"
label="√"/>
</mx:Application>
Reply all
Reply to author
Forward
0 new messages