Comunidad de diseño web y desarrollo en internet online

Botones de texto como en de www.pho-ku.com

Citar            
MensajeEscrito el 29 Jul 2010 03:20 pm
iHola.Queria crear un texto dinámico (algo similar al de http://www.pho-ku.com/ ) que tiene dos entradas, una se muestra cuando estas sobre el campo y la otra cuando estas fuera. Los caracteres se añaden con un Timer, bueno tengo dos uno para cada situacion(tal vez sea posible reducirlo a uno). El problema es que si hago Over y Out muy deprisa se mezclan los textos, e intentado parar los timers o los listeners pero no me ha funcionado o no he sabdi hacerlo.
Este es el codigo

Código ActionScript :

import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.events.MouseEvent;


var texto:TextField = new TextField ();
texto.text = "11111111111111";  //texto "11111111111"
var texto2:TextField = new TextField ();
texto2.text = "22222222"; //texto2 "22222222222"
var textomatrix:TextField = new TextField();
textomatrix.width=80;
textomatrix.height=30;
addChild(textomatrix); //Campo de texto Dinámico ( ¿Es TextField dinámico o de de usar otra clase?)
textomatrix.addEventListener(MouseEvent.ROLL_OVER, onOver); //Escuchador OVER
textomatrix.addEventListener(MouseEvent.ROLL_OUT, onOut);  //Escuchador OUT
var i:Number = new Number(); //contador
function onOver (event:MouseEvent):void
{

   textomatrix.text = "";
   i=-1;
   var temporizador:Timer = new Timer (60,texto.text.length);//tiempo entre cambios
   temporizador.addEventListener(TimerEvent.TIMER, funciontempo1);
   temporizador.start();

   function funciontempo1 (event:TimerEvent):void
   {      
         i+=1;
         textomatrix.text = textomatrix.text + texto.text.charAt(i);
   }
   trace("onIn");
}
function onOut (event:MouseEvent):void
{

   textomatrix.text = "";
   i=-1;
   var temporizador2:Timer = new Timer (60,texto2.text.length);//tiempo entre cambios
   temporizador2.addEventListener(TimerEvent.TIMER, funciontempo2);
   temporizador2.start();

   function funciontempo2 (event:TimerEvent):void
   {
         i+=1;
         textomatrix.text = textomatrix.text + texto2.text.charAt(i);
   }

   trace("onOut");
}

Por Luis Borja

17 de clabLevel



 

msie
Citar            
MensajeEscrito el 29 Jul 2010 05:54 pm
Vale ya lo tengo, hice algunos cambios pero lo principal es que saque las funcionestempo fuera de las de OVER y OUT, y despues remover los listener al hacer OVER y OUT, de esa forma ya no se mezclan los textos.

Por Luis Borja

17 de clabLevel



 

msie

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.