Comunidad de diseño web y desarrollo en internet online

Cargar diferentes textos a un efecto

Citar            
MensajeEscrito el 07 May 2007 11:10 pm
hola que tal espero que me puedan ayudar tengo este codigo:

Código :

import mx.utils.Delegate;
mystring = "Lograr ser el Inversionista (jugador) que, sumando el valor de sus inversiones y dinero, quede con más capital acumulado para seguir conservando las maravillas de México, o ser el único participante que no quede en quiebra, es decir, sin dinero.";
mystring2 = "El interactivo entrará con un mapa de la República Mexicana que se ve a los lejos y que se acerca rápidamente hasta disolverse. Inmediatamente después, aparecerán indistintamente personajes de la Historia de México.";
// --
var myformat:TextFormat = new TextFormat();
myformat.font = 'Verdana';
myformat.size = 10;
myformat.align = 'justify';
mcText.mytext.setNewTextFormat(myformat);
mcText.mytext.html = true;
mcText.mytext.multiline = true;
mcText.mytext.wordWrap = true;
//
var interval:Number;
var string:String;
var speed:Number;
var textfield:TextField;
var index:Number;
//
//Typewriter(mcText.mytext, mystring2, 20);
esperate = setInterval(this, "Typewriter", 6000, mcText.mytext, mystring, 20);
//
function Typewriter(textfield:TextField, string:String, speed:Number) {
   this.textfield = textfield;
   this.string = string;
   this.speed = speed;
   index = 0;
   interval = setInterval(Delegate.create(this, exec), this.speed);
}
//
function exec() {
   this.textfield.text = this.string.substr(0, index);
   index++;
   if (index>this.string.length) {
      clearInterval(interval);
      clearInterval(esperate);
   }
}

Lo que realiza es un efecto tipo maquina de escribir , ya hace uno pero lo que quiero es cargar diferentes textos de informacion, mi idea era hacerlo con diferentes setInterval para cada texto pero siento que es mucho, que me recomiendan hacer, otra cosa cuando termina de escribir mi texto lo quiero desaparecer con un simple funcion:

Código :


function alpha() {
   new mx.transitions.Tween(mcText, "_alpha", mx.transitions.easing.Strong.easeOut, 100, 0, 4, true);
   clearInterval(espera);
}
espera = setInterval(alpha, 2000);
}

y claro no me realiza el efecto , el texto dinamico esta dentro de "mcText" que estoy haciendo mal
Gracias

Por joshuavw

Claber

306 de clabLevel



Genero:Masculino  

Juego, aprendo y programo

msie7
Citar            
MensajeEscrito el 10 May 2007 09:14 pm
Bueno me respondo yo solo y alguien me ayudo de otro sitio espero que les funcione como a mi
baje la clase de un tutorial de after Typewriter.as

Código :

import mx.utils.Delegate;
class Typewriter  {
   private var interval:Number;
   private var string:String;
   private var speed:Number;
   private var textfield:TextField;
   private var index:Number;
   public function Typewriter (textfield:TextField, string:String, speed:Number) {
      this.textfield = textfield;
      this.string = string;
      this.speed = speed;
      index = 0;
      interval = setInterval(Delegate.create(this, exec), this.speed);
   }
   private function exec() {
      this.textfield.text = this.string.substr(0, index);
      index++;
      if (index > this.string.length) {
         clearInterval(interval);
      }
   }
}

y en el fla solo necesite esto:

Código :

estado = ["Baja California Sur", "Baja California Norte", "Sonora", "Sinaloa"]
lugar=["Cabo San Lucas.", "Pinturas Rupestres.", "El pinacate.", "Mazatlán."]
var myformat:TextFormat = new TextFormat();
myformat.font = 'Verdana';
myformat.size = 10;
myformat.align = 'justify';
mcText.mytext.embedFonts = true;
mcText.mytext.antiAliasType = "advanced";
mcText.mytext.setNewTextFormat(myformat);
mcText.mytext.html = true;
mcText.mytext.multiline = true;
mcText.mytext.wordWrap = true;
//
cuenta = 0;
textos = 3;
//esperando = setInterval(alpha, 15000);
carga = setInterval(CargarTextos, 5000);
//
function CargarTextos() {
   intervalo = setInterval(function () {
      new Typewriter(mcText.mytext, estado[cuenta++]+": "+lugar[cuenta], 20);
      trace("Cuenta:"+cuenta);
      if (cuenta == textos) {
         trace("Terminado");
         clearInterval(intervalo);
      }
   }, 3000);
   clearInterval(carga);
}
//
function alpha() {
   new mx.transitions.Tween(mcText, "_alpha", mx.transitions.easing.Strong.easeIn, 100, 0, 2, true);
   clearInterval(esperando);
}
//

Donde en 8 segundos carga mi funcion tiempo y cada 3 seg cambia la informacion de mi texto dinamico y que rango cuando llego el limite borra los intervalos
Espero que les sirva.

P.D. Si los cargo los datos en un XML ya que va a tener un atributo como la direccion de la foto de cada uno como se podria hacer ahora ?
Saludos.

Por joshuavw

Claber

306 de clabLevel



Genero:Masculino  

Juego, aprendo y programo

msie7

 

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