Tema: sumar
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/06/2007, 07:26
Nornor
 
Fecha de Ingreso: junio-2007
Mensajes: 37
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: sumar

Gracias por tu pronta respuesta Mahalo.
Lo he intentado con este código pero me sigue saliendo una suma como esta: 3+3=33
Quizas he escrito mal el código.
Código:
idcamposuma.text=idcampo1.text+idcampo2.text;
var a:Number = new Number (idcampo1.text);
var b:Number = new Number (idcampo2.text);
var c:Number = new Number (a+b);
idcamposuma.text = c;
botonsuma.onRelease=function(){idcamposuma.text=idcampo1.text+idcampo2.text;}
botonborrar.onRelease=function(){idcamposuma.text="";idcampo1.text="";idcampo2.text="";}
en cambio me han dicho que ponga la función global Number(str) así:
Código:
botonsuma.onRelease=function(){idcamposuma.text=Number(idcampo1.text)+Number(idcampo2.text);}
y si funciona.
Un saludo