Comunidad de diseño web y desarrollo en internet online

desactivar boton durante tween

Citar            
MensajeEscrito el 18 Ago 2008 03:49 pm
Hola,

Tengo una imagen convertida en mc.
He usado un tween para que no aparezca de golpe.

Código :

var miTween:Tween = new new Tween(foto1, "_y", Bounce.easeOut, 84, 105.7, 3, true);


Tras esto uso otro tween (haciendo click) para que se coloque en otra posición haciendo zoom.

Código :

foto1.onRelease = function() {         
new mx.transitions.Tween(this, "_width", mx.transitions.easing.Regular.easeOut, this._width, 575, 5);
}


El caso es que, si hago click durante el primer tween, antes de que se coloque, hace cosas raras como irse a otra posición en el zoom.

¿Cómo puedo hacer que no se pueda hacer click hasta que no termine el primer tween?

Gracias!

Por Onexete

76 de clabLevel



Genero:Masculino  

msie7
Citar            
MensajeEscrito el 18 Ago 2008 04:02 pm
Puedes utilizar algo como esto, deshabilitar el boton y habilitarlo cuando termine el Tween con el evento onMotionFinished:

Código ActionScript :

//---Declaras el objeto Tween

import mx.transitions.Tween;

var myTween:Tween = new Tween(_rot.caja, "_width", mx.transitions.easing.Regular.easeOut, _root.caja._width, 575, 5);

//---Evento para cuando el Tween finalice

myTween.onMotionFinished = function() {

    _root.boton.enabled = true;

};

//---Le das la orden al tween de comenzar cuando se presione el botón

_root.boton.onRelease = function():Void{

    //---Se deshabilita el botón

    this.enabled = false;
    
    myTween.start();

}

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 18 Ago 2008 04:28 pm
Estoy hecho un lío y no sé donde poner lo que me indicas, a pesar de que está muy bien explicado.

Código ActionScript :

El problema es que no sé mucho de código y evidentemente este no es mío, pero para que veas lo que tengo te pongo el churro:

import mx.transitions.Tween;
import mx.transitions.easing.*;


var miTween:Tween = new new Tween(foto1, "_y", Bounce.easeOut, 84, 105.7, 3, true);
var miTween:Tween = new new Tween(foto2, "_y", Bounce.easeOut, 144.5, 166.2, 3, true);


var NumFotos = 3;
//Hay que poner una más de las que sean
var PosXFinal = 483.5;
var PosYFinal = 317;
titulo3.swapDepths(2000);
texto1.text="Haz click en cada fotografía para verla con más detalle";
datos = new Array();
datos[1] = "Cremalleras";
datos[2] = "Ojales a contraste";

var c = 0.75;
var k = 0.06;
for (i=1; i<NumFotos; i++) {
                this["foto"+i].Xinic = this["foto"+i]._width;
   this["foto"+i].Yinic = this["foto"+i]._height;
   this["foto"+i].posX = this["foto"+i]._x;
   this["foto"+i].posY = this["foto"+i]._y;
   this["foto"+i].estado = 0;
   this["foto"+i].valor = i;
   
   this["foto"+i].onRelease = function():Void {      
            
      if (this.estado == 0) {
      this.estado = 1;         
   new mx.transitions.Tween(this, "_width", mx.transitions.easing.Regular.easeOut, this._width, 575, 5);
   new mx.transitions.Tween(this, "_height", mx.transitions.easing.Regular.easeOut, this._height, 500, 5);
   new mx.transitions.Tween(this, "_x", mx.transitions.easing.Regular.easeOut, this._x, PosXFinal, 5);
   new mx.transitions.Tween(this, "_y", mx.transitions.easing.Regular.easeOut, this._y, PosYFinal, 5);
      this.swapDepths(1000);
      texto1.text = datos[this.valor];
   } else {
   this.estado = 0;
   new mx.transitions.Tween(this, "_width", mx.transitions.easing.Regular.easeOut, this._width, this.Xinic, 5);
   new mx.transitions.Tween(this, "_height", mx.transitions.easing.Regular.easeOut, this._height, this.Yinic, 5);
   new mx.transitions.Tween(this, "_x", mx.transitions.easing.Regular.easeOut, PosXFinal, this.posX, 5);
   new mx.transitions.Tween(this, "_y", mx.transitions.easing.Regular.easeOut, PosYFinal, this.posY+21.7, 5);
   texto1.text = "Haz click en cada fotografía para verla con más detalle";
      }
   };
}


:swat: usa code, gracias.

Por Onexete

76 de clabLevel



Genero:Masculino  

msie7
Citar            
MensajeEscrito el 18 Ago 2008 06:49 pm
Utiliza una variable global para definir el Tween:

Código ActionScript :

import mx.transitions.Tween;    
var myTween:Tween = new Tween(_rot.caja, "_width", mx.transitions.easing.Regular.easeOut, _root.caja._width, 575, 5);


En vez de hacerlo directo dentro del botón:

Código ActionScript :

new mx.transitions.Tween(this, "_width", mx.transitions.easing.Regular.easeOut, this._width, 575, 5);  


Así podrás asignarle eventos a esta variable.

La verdad nunca me han gustado las transiciones propias de flash, ya por el consumo de recursos, como por lo complicado, por ejemplo estas cuatro líneas de código que has posteado:

Código ActionScript :

new mx.transitions.Tween(this, "_width", mx.transitions.easing.Regular.easeOut, this._width, 575, 5);  
new mx.transitions.Tween(this, "_height", mx.transitions.easing.Regular.easeOut, this._height, 500, 5);  
new mx.transitions.Tween(this, "_x", mx.transitions.easing.Regular.easeOut, this._x, PosXFinal, 5);  
new mx.transitions.Tween(this, "_y", mx.transitions.easing.Regular.easeOut, this._y, PosYFinal, 5);


Con TweenMax utilizando una función para que me avise cuando se terminó la animación se traducen en:

Código ActionScript :

TweenMax.to(this, 5, {_x:posXFinal, _y:posYFinal, _width:575, _height:500, ease:Regular.easeOut, onComplete:tellMe});

function tellMe():Void{

    trace("se completó la animación");

}

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 18 Ago 2008 06:57 pm
Bueno, ahora me toca estudiar a ver si soy capaz.

De lo que no hay duda es de que me romperé los cuernos para sacarlo. Creo que es la mejor manera de agradecer el tiempo que me has dedicado.

Muchas gracias!!!

Por Onexete

76 de clabLevel



Genero:Masculino  

msie7
Citar            
MensajeEscrito el 18 Ago 2008 07:02 pm
Por qué mejor no te decargas TweenMax y todo te saldrá más fácil y aparte tus animaciones irán más fluidas y sin consumir tantos recursos.

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox

 

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