Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/05/2012, 06:07
Avatar de Silkon
Silkon
 
Fecha de Ingreso: mayo-2011
Ubicación: Lugo
Mensajes: 201
Antigüedad: 13 años
Puntos: 20
Respuesta: Cambiar texto con botones

Hola, antes de que alguien te pegue un codigo con algo parecido y diez mil cosas mas.... xDDD

Es tan facil que te lo hice en un momento en un código limpio y ordenado ;)


Código AS3:
Ver original
  1. var texto1:String = "";
  2. var texto2:String = "";
  3.  
  4.  
  5. b1.addEventListener(MouseEvent.CLICK, dicehola);
  6. function dicehola(event:MouseEvent):void
  7. {
  8.    
  9.     if (texto1 == "")
  10.         {
  11.             texto1 = "Hola";
  12.             campotexto.text = texto1+" "+texto2;
  13.         }
  14.        
  15.     else if (texto1 == "Hola")
  16.         {
  17.             texto1 = "";
  18.             campotexto.text = texto1+" "+texto2;
  19.         }
  20.    
  21.    
  22.    
  23. }
  24.    
  25. b2.addEventListener(MouseEvent.CLICK, dicegato);
  26. function dicegato(event:MouseEvent):void
  27. {
  28.    
  29.     if (texto2 == "")
  30.         {
  31.             texto2 = "Gato";
  32.             campotexto.text = texto1+" "+texto2;
  33.         }
  34.        
  35.     else if (texto2 == "Gato")
  36.         {
  37.             texto2 = "";
  38.             campotexto.text = texto1+" "+texto2;
  39.         }
  40.    
  41.    
  42.    
  43. }