Comunidad de diseño web y desarrollo en internet online

ultimo frame de linea de tiempo

Citar            
MensajeEscrito el 28 Oct 2011 05:52 pm
Hola


quisiera saber como disparar una funcion cuando mi linea de tiempo (en la raiz) llegue al final, sin importar cuandos frame tenga

algo como:

if(ultimoFrame){
haga algo;
}


Thanks

Por dianita666

Claber

185 de clabLevel



 

firefox
Citar            
MensajeEscrito el 28 Oct 2011 07:55 pm
Hola. Los MC tienen propiedades que te ayudan a realizar eso.
Por ejemplo (teniendo en cuenta que mc es el nombre de instancia de un movieclip) si escribis

Código ActionScript :

mc.currentFrame
te devuelve el frame actual y

Código ActionScript :

mc.totalFrames
el total de frames que tiene dicho mc.
Entonces con un simple

Código ActionScript :

if(mc.currentFrame == mc.totalFrames)
logras lo que pedis.

Saludos

Por GustavoV

Claber

136 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 09 Nov 2011 01:51 pm
Gracias!!

pero fijate que probe eso mismo en la linea de tiempo principal y no funciono:

if(this.currentFrame == this.totalFrames){
this.gotoAndStop(1);
}

porque sera?

Thanks

Por dianita666

Claber

185 de clabLevel



 

firefox
Citar            
MensajeEscrito el 11 Nov 2011 07:40 pm
dianita666, creería que tu problema está con la actualización de esa condicional. Si no actualiza de vez en cuando, esa condicional se comprueba por única vez y luego deja de leerse, y por eso no llega a cumplirse. Estás utilizando onEnterFrame, por ejemplo?. En fin sería algo como lo siguiente:

Código ActionScript :

//le asignamos el listener ENTER_FRAME a la línea de tiempo, y con ello la funcion "detectarUltimo"
this.addEventListener(Event.ENTER_FRAME, detectarUltimo);

//esta function se ejecuta por cada Frame nuevo en tiempo de ejecución
function detectarUltimo(event:Event):void {
   //si el Frame actual es igual al total...
   if (event.target.currentFrame==event.target.totalFrames) {
      //vamos al primer Frame
      event.target.gotoAndStop(1);
      //y con ello destruimos el listener
      this.removeEventListener(Event.ENTER_FRAME,detectarUltimo);
   }
}

Bueno, espero haberte ayudado :P

Por liamb

2 de clabLevel



 

firefox

 

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