Tengo el siguiente problema, estoy realizando una sección de noticias al estilo de una "Galería de imágenes", esta galería de imágenes cuenta con un botón de "siguiente" y uno de "anterior".
El as3 lo hice con base en el tipo de variable Boolean, es decir, cada noticia tiene una variable, en total son 3 noticias, la que aparece al principio pues es la Noticia1, que será igual a "true", y las demás serán "false". Bueno cree la función del botón, y todo iba bien, pero tengo un problema, a veces cuando oprimo el botón de siguiente no se cumple lo que yo quiero, es decir, si estoy en la Noticia2 y oprimo siguiente quiero que se reproduzca la animación de entrada de la Noticia3, pero hay momento en que no es así, si no que de pronto se pasa a la Noticia1, o cosas así. Lo mas raro, es que a veces funciona bien y otras veces no. Alguien me puede ayudar?
Aquí esta el código:
var NoticiaUno:Boolean = true;
var NoticiaDos:Boolean = false;
var NoticiaTres:Boolean = false;
Siguiente_btn.addEventListener(MouseEvent.CLICK, siguiente);
//Siguiente
function siguiente(event:MouseEvent)
{
if(NoticiaUno == true)
{
NoticiaDos = false;
NoticiaTres = false;
if (Noticia2_mc.currentFrame == 1)
{
var desplazar1:Tween = new Tween(Noticia1, "x", Regular.easeInOut, -266, -888.20, 15, false);
var desplazar2:Tween = new Tween(Noticia2, "x", Regular.easeInOut, 356.05, -266, 15, false);
NoticiaUno = false;
NoticiaDos = true;
NoticiaTres = false;
}
else if (Noticia2_mc.currentFrame == 100)
{
Noticia2_mc.gotoAndStop(1);
var desplazar3:Tween = new Tween(Noticia1, "x", Regular.easeInOut, -266, -888.20, 15, false);
var desplazar4:Tween = new Tween(Noticia2, "x", Regular.easeInOut, 356.05, -266, 15, false);
NoticiaUno = false;
NoticiaDos = true;
NoticiaTres = false;
}
}
else if(NoticiaDos == true)
{
NoticiaUno = false;
NoticiaTres = false;
if (Noticia3_mc.currentFrame == 1)
{
var desplazar7:Tween = new Tween(Noticia2, "x", Regular.easeInOut, -266, -888.20, 15, false);
var desplazar8:Tween = new Tween(Noticia3, "x", Regular.easeInOut, 356.05, -266, 15, false);
NoticiaDos = false;
NoticiaTres = true;
NoticiaUno = false;
}
else if (Noticia3_mc.currentFrame == 100)
{
Noticia3_mc.gotoAndStop(1);
var desplazar9:Tween = new Tween(Noticia2, "x", Regular.easeInOut, -266, -888.20, 15, false);
var desplazar10:Tween = new Tween(Noticia3, "x", Regular.easeInOut, 356.05, -266, 15, false);
NoticiaDos = false;
NoticiaTres = true;
NoticiaUno = false;
}
}
else if (NoticiaTres == true)
{
NoticiaUno = false;
NoticiaDos = false;
if (Noticia1_mc.currentFrame == 1)
{
var desplazar13:Tween = new Tween(Noticia3, "x", Regular.easeInOut, -266, -888.20, 15, false);
var desplazar14:Tween = new Tween(Noticia1, "x", Regular.easeInOut, 356.05, -266, 15, false);
NoticiaTres = false;
NoticiaUno = true;
NoticiaDos = false;
}
else if (Noticia1_mc.currentFrame == 100)
{
Noticia1_mc.gotoAndStop(1);
var desplazar15:Tween = new Tween(Noticia3, "x", Regular.easeInOut, -266, -888.20, 15, false);
var desplazar16:Tween = new Tween(Noticia1, "x", Regular.easeInOut, 356.05, -266, 15, false);
NoticiaTres = false;
NoticiaUno = true;
NoticiaDos = false;
}
}
}