Comunidad de diseño web y desarrollo en internet online

bloquear un objeto con scripts

Citar            
MensajeEscrito el 18 Abr 2007 03:51 pm
hola, tengo una duda

en un drag and drop quiero que cuando coincida con su destino ya no se pueda mover mas
este es mi codigo

Código :

origX = garbage_mc._x;
origY = garbage_mc._y;

garbage_mc.onPress = function() {
   this.startDrag();
}
garbage_mc.onRelease = function() {
    if (this.hitTest(trashcan_mc)) {
    this.stopDrag();
      _root.great.gotoAndPlay(2);
   this._x = trashcan_mc._x;
    this._y = trashcan_mc._y;
   

   
   
    }  else if(this.hitTest(basura)){
      this.stopDrag();
      trace("Try Again");
        this._x = origX;
    this._y = origY;
      }
      else {
   this.stopDrag();
    this._x = origX;
    this._y = origY;
    }
};


gracias!

Por johnpaga

12 de clabLevel



 

firefox
Citar            
MensajeEscrito el 19 Abr 2007 09:19 am
Fácil!
Cuando detectas colisión eliminas el evento onPress y ya no se difundirá:

Código :

if (this.hitTest(trashcan_mc)) {
    this.stopDrag();
      _root.great.gotoAndPlay(2);
   this._x = trashcan_mc._x;
    this._y = trashcan_mc._y;

    delete this.onPress; // Aqui borra el onPress
} 

Hay otras maneras, pero esta creo que es la más óptima. :)

Por micheloud

341 de clabLevel



 

Misiones, Argentina

firefox
Citar            
MensajeEscrito el 19 Abr 2007 05:37 pm
muchisimas graciasª!!!!!!!!!!!!!!!!!!
=D

kedo perfecto!

Por johnpaga

12 de clabLevel



 

firefox
Citar            
MensajeEscrito el 19 Abr 2007 06:13 pm
XD me alegro!

Por micheloud

341 de clabLevel



 

Misiones, Argentina

firefox

 

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