Dios odio cuando abres Flash y lo que ayer funcionaba ahora no lo hace..Mira esta es mi clase, al instanciar le das los valores de texto y texto 2. Ayer funcionaba a la perfeccion excepto q el timer no paraba, ahora al abrirlo tampoco se kita el primer texto al hacer OVer, no se, algo muy raro, creo que es un bug (lo que me faltaba).
Código ActionScript :
package {
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.media.Sound;
import flash.net.URLRequest;
public class TextRepublic extends TextField
{
public var texto:String="";
public var texto2:String="";
public var sonido:Sound = new Sound();
public var sonido2:Sound= new Sound();
public var contador:int=-1;
public var tempo:Timer;
public var tempo2:Timer;
public function TextRepublic()
{
this.tempo = new Timer(120,10);
this.tempo2 = new Timer(120,10);
this.sonido.load(new URLRequest("soni1.mp3"));
this.addEventListener(MouseEvent.ROLL_OVER, onOver);
this.addEventListener(MouseEvent.ROLL_OUT, onOut);
this.tempo2.addEventListener(TimerEvent.TIMER, funciontempo2);
this.tempo2.start();
// constructor code
}
public function onOver (event:MouseEvent):void
{
this.text = "";
this.contador = -1;
this.tempo2.removeEventListener(TimerEvent.TIMER, funciontempo2);
this.tempo.addEventListener(TimerEvent.TIMER, funciontempo1);
this.tempo.reset();
this.tempo.start();
}
public function onOut (event:MouseEvent):void
{
this.text = "";
this.contador = -1;
this.tempo.removeEventListener(TimerEvent.TIMER, funciontempo1);
this.tempo2.addEventListener(TimerEvent.TIMER, funciontempo2);
this.tempo2.reset();
this.tempo2.start();
}
public function funciontempo1 (event:TimerEvent):void
{
this.contador+=1;
this.appendText(texto.charAt(contador));
this.sonido.play();
}
public function funciontempo2 (event:TimerEvent):void
{
this.contador+=1;
this.appendText(texto2.charAt(contador));
}
}
}