Está en la página 1de 3

var xopera:String;

var xcantidad1:String;
var xcantidad2:String;
var xresul:int;

textoaqui.text ="";

boton_9.addEventListener(MouseEvent.CLICK, apretar9);
function apretar9(event:MouseEvent):void
{ textoaqui.text=textoaqui.text + "9"; }

boton_8.addEventListener(MouseEvent.CLICK, apretar8);
function apretar8(event:MouseEvent):void
{ textoaqui.text=textoaqui.text + "8"; }

boton_7.addEventListener(MouseEvent.CLICK, apretar7);
function apretar7(event:MouseEvent):void
{ textoaqui.text=textoaqui.text + "7"; }

boton_6.addEventListener(MouseEvent.CLICK, apretar6);
function apretar6(event:MouseEvent):void
{ textoaqui.text=textoaqui.text + "6"; }

boton_5.addEventListener(MouseEvent.CLICK, apretar5);
function apretar5(event:MouseEvent):void
{ textoaqui.text=textoaqui.text + "5"; }

boton_4.addEventListener(MouseEvent.CLICK, apretar4);
function apretar4(event:MouseEvent):void
{ textoaqui.text=textoaqui.text + "4"; }

boton_3.addEventListener(MouseEvent.CLICK, apretar3);
function apretar3(event:MouseEvent):void
{ textoaqui.text=textoaqui.text + "3"; }

boton_2.addEventListener(MouseEvent.CLICK, apretar2);
function apretar2(event:MouseEvent):void
{ textoaqui.text=textoaqui.text + "2"; }

boton_1.addEventListener(MouseEvent.CLICK, apretar1);
function apretar1(event:MouseEvent):void
{ textoaqui.text=textoaqui.text + "1"; }

boton_0.addEventListener(MouseEvent.CLICK, apretar0);
function apretar0(event:MouseEvent):void
{ textoaqui.text=textoaqui.text + "0"; }

borra.addEventListener(MouseEvent.CLICK, borrac);
function borrac(event:MouseEvent):void
{ textoaqui.text= ""; }

simbolo_mas.addEventListener(MouseEvent.CLICK, mmsuma);
function mmsuma(event:MouseEvent):void
{
xopera="suma";
xcantidad1=textoaqui.text
textoaqui.text="";
trace(xopera);
trace(xcantidad1);

simbolo_menos.addEventListener(MouseEvent.CLICK, mmresta);
function mmresta(event:MouseEvent):void
{
xopera="resta";
xcantidad1=textoaqui.text
textoaqui.text="";
trace(xopera);
trace(xcantidad1);

simbolo_mult.addEventListener(MouseEvent.CLICK, mmmult);
function mmmult(event:MouseEvent):void
{
xopera="mult";
xcantidad1=textoaqui.text
textoaqui.text="";
trace(xopera);
trace(xcantidad1);

simbolo_div.addEventListener(MouseEvent.CLICK, mmdiv);
function mmdiv(event:MouseEvent):void
{
xopera="divi";
xcantidad1=textoaqui.text
textoaqui.text="";
trace(xopera);
trace(xcantidad1);

simbolo_igual.addEventListener(MouseEvent.CLICK, yyigual);
function yyigual(event:MouseEvent):void
{
xcantidad2 = textoaqui.text;
textoaqui.text = "";
if(xopera == "suma")
{ xresul = parseFloat(xcantidad1) + parseFloat(xcantidad2);
textoaqui.text = xresul.toString() ;

}
if(xopera == "resta")
{ xresul = parseFloat(xcantidad1) - parseFloat(xcantidad2);
textoaqui.text = xresul.toString() ;

}
if(xopera == "mult")
{ xresul = parseFloat(xcantidad1) * parseFloat(xcantidad2);
textoaqui.text = xresul.toString() ;

}
if(xopera == "divi")
{ xresul = parseFloat(xcantidad1)/parseFloat(xcantidad2);
textoaqui.text = xresul.toString() ;

xcantidad2 = "";
xcantidad1 = "";
}

También podría gustarte