todo los botones tiene el nombre adecuado.
Código ActionScript :
var output:String = ""; var multiplier_old:Number = 10; var multiplier_new:Number = 1; var point:Boolean = false; var action:String = ""; var solution:Number; var input:Number = 0; var state:Number = 1; input_1.onPress = function() { inputNumber(1); } input_2.onPress = function() { inputNumber(2); } input_3.onPress = function() { inputNumber(3); } input_4.onPress = function() { inputNumber(4); } input_5.onPress = function() { inputNumber(5); } input_6.onPress = function() { inputNumber(6); } input_7.onPress = function() { inputNumber(7); } input_8.onPress = function() { inputNumber(8); } input_9.onPress = function() { inputNumber(9); } input_0.onPress = function() { inputNumber(0); } action_equals.onPress = function() { calculate(true); }; action_point.onPress = function() { multiplier_old = 1; multiplier_new = 0.1; point = true; }; action_state.onPress = function() { state *= -1; } action_add.onPress = function() { setAction("+"); }; action_divide.onPress = function() { setAction("/"); }; action_subtract.onPress = function() { setAction("-"); }; action_multiply.onPress = function() { setAction("*"); }; action_clear.onPress = function() { input = 0; point = false; multiplier_old = 10; multiplier_new = 1; state = 1; output = input.toString(); } action_clearall.onPress = function() { solution = undefined; action = ""; action_clear.onPress(); } function inputNumber(n:Number):Void { input = input*multiplier_old + n*multiplier_new; if (point) multiplier_new *= 0.1; output = input.toString(); } function setAction(a:String):Void { calculate(); action = a; } function calculate(end:Boolean):Void { input *= state; if (solution == undefined) { solution = input; } else { switch(action) { case "+": solution += input; break; case "-": solution -= input; break; case "*": solution *= input; break; case "/": solution /= input; break; } } output = solution.toString(); input = 0; point = false; multiplier_old = 10; multiplier_new = 1; state = 1; action = ""; if (end) solution = undefined; }