Flash función sleep

  • Rabid Dog
  • Web Master
  • Web Master
  • Avatar de Usuario
  • Registrado: May 21, 2004
  • Mensajes: 3229
  • Loc: South Africa
  • Status: Offline

Nota Noviembre 3rd, 2004, 2:28 am

Hola a todos. Hizo una búsqueda y no puedo encontrar lo que estoy buscando.

Necesito una función de tipo de sueño en Flash MX. Lo que estoy tratando de hacer es animar un clip de película en movimiento a un punto específico. El punto que necesita para pasar a se recupera de un documento XML.

Código: [ Select ]
function animateCard(tPos){
    startY = _root.card_mc._y * -1;
    startX = _root.card_mc._x;
    _root.output += "\nStart Y: " + startY ; // debug
    _root.output += "\nStart X: " + startX ; // debug
    for (i = 0; i < tPos; i++){
     _root.card_mc._y = i;
     
    }
}
  1. function animateCard(tPos){
  2.     startY = _root.card_mc._y * -1;
  3.     startX = _root.card_mc._x;
  4.     _root.output += "\nStart Y: " + startY ; // debug
  5.     _root.output += "\nStart X: " + startX ; // debug
  6.     for (i = 0; i < tPos; i++){
  7.      _root.card_mc._y = i;
  8.      
  9.     }
  10. }


Esta es la función que estoy utilizando. El problema es que el bucle se ejecuta tan rápido que ocurre casi instantáneamente.

¿Alguna idea?
Watch me grow
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Noviembre 3rd, 2004, 2:28 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Registrado: Feb 10, 2004
  • Mensajes: 13455
  • Loc: Florida
  • Status: Offline

Nota Noviembre 3rd, 2004, 3:35 am

onEnterFrame.

Trabaja en la película de FPS (fotogramas por segundo). Si el FPS es de 20 la función asignada al evento onEnterFrame se ejecutará (aprox.) 20 veces por segundo.
sustituir el bucle,
Código: [ Select ]
_root.card_mc.tPos = tPos;
_root.card_mc.onEnterFrame = function(){
  if(this._y < this.tPos){
   this._y++;
  }else{
   delete this.onEnterFrame;
  }
}
  1. _root.card_mc.tPos = tPos;
  2. _root.card_mc.onEnterFrame = function(){
  3.   if(this._y < this.tPos){
  4.    this._y++;
  5.   }else{
  6.    delete this.onEnterFrame;
  7.   }
  8. }


onEnterFrame es lo más cercano a un sueño como flash consigue. (a menos que jugar con setInterval...dolor de cabeza ..) Loops finalizar su ejecución antes de que los cambios se hacen realmente en la pantalla.
Strong with this one, the sudo is.
  • Rabid Dog
  • Web Master
  • Web Master
  • Avatar de Usuario
  • Registrado: May 21, 2004
  • Mensajes: 3229
  • Loc: South Africa
  • Status: Offline

Nota Noviembre 3rd, 2004, 3:40 am

Gracias por ello. Readin su publicación ahora me di cuenta de cómo hacerlo. Simplemente no podía obtener mi cerebro a pensar!

Gracias de nuevo por que, lo hará ahora!
Watch me grow
  • Jaw
  • Graduate
  • Graduate
  • Avatar de Usuario
  • Registrado: Nov 08, 2004
  • Mensajes: 132
  • Loc: Minneapolis, MN
  • Status: Offline

Nota Noviembre 8th, 2004, 7:41 pm

Im seguro usted averiguado, pero aquí es un poco de ayuda para cualquier otra persona que lo necesite. ¡Salud!.

Código: [ Select ]
//----The Deep Freeze by Jaw (jake.at.elementsmedia.net)
this.onEnterFrame = function() {
    theActiveGoods();
    deepfreeze = 1;
};
this.onMouseDown = function() {
    if (deepfreeze == 1) {
        //Mouse click stops animation
        delete this.onEnterFrame;
        deepfreeze = 0;
    } else {
        //Mouse click starts animation
        this.onEnterFrame = function() {
            theActiveGoods();
            deepfreeze = 1;
        };
    }
};
  1. //----The Deep Freeze by Jaw (jake.at.elementsmedia.net)
  2. this.onEnterFrame = function() {
  3.     theActiveGoods();
  4.     deepfreeze = 1;
  5. };
  6. this.onMouseDown = function() {
  7.     if (deepfreeze == 1) {
  8.         //Mouse click stops animation
  9.         delete this.onEnterFrame;
  10.         deepfreeze = 0;
  11.     } else {
  12.         //Mouse click starts animation
  13.         this.onEnterFrame = function() {
  14.             theActiveGoods();
  15.             deepfreeze = 1;
  16.         };
  17.     }
  18. };

Publicar Información

  • Total de mensajes en este tema: 4 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 37 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC