Comunidad de diseño web y desarrollo en internet online

drag and drop y loadmovie

Citar            
MensajeEscrito el 09 Jul 2009 12:22 am
Buenas noches a todos los foristas,

Rebuscando por toda la web no consigo solucionar este problema, que paso a explicar.

He bajado un juego de drag and drop el cual es este http://www1.appstate.edu/~midgetta/media/flash/tutorials/draganddrop2/draganddrop2CODE2.fla

yo he modificado el diseño, para adaptarlo a mi site, pero tengo un problema este juego lo llamo desde un load movie

Código ActionScript :

on (release) {
   loadMovieNum("evaluacion0.swf", 10);
}


Pero cuando llamo la animacion desde la pelicula madre los elementos no se pegan, cuando ejecuto el swf del juego funciona se arrastran y los elementos cuando coinciden se pegan, les pongo el codigo que esta en el primer frame para ver si solo es poner algun parent o this, pero la verdad ya me tome todo un dia y no encuentro por donde... muchas gracias por leer este mensaje y ojala puedan absolver mi duda.

Código ActionScript :

arm.onPress = function() { 
arm.startDrag();
};
arm.onRelease = function() { 
stopDrag();
if (arm._droptarget == "/arm1") {
arm._x = 237.0;
arm._y = 554.6;
if 
(arm._droptarget == "/arm1" && neck._droptarget == "/neck1" && foot._droptarget == "/foot1" && head._droptarget == "/head1" && legs._droptarget == "/leg1" && hand._droptarget == "/hand1"){
nextFrame();}

} else {
arm._x = 336.4;
arm._y = 47.1;

}
};
//

neck.onPress = function() { 
neck.startDrag();
};
neck.onRelease = function() { 
stopDrag();
if (neck._droptarget == "/neck1") {
neck._x = 237.0;
neck._y = 523.7;
if 
(arm._droptarget == "/arm1" && neck._droptarget == "/neck1" && foot._droptarget == "/foot1" && head._droptarget == "/head1" && legs._droptarget == "/leg1" && hand._droptarget == "/hand1"){
nextFrame();}
} else {
neck._x = 203.9;
neck._y = 63.1;

}
};
//
//

foot.onPress = function() { 
foot.startDrag();
};
foot.onRelease = function() { 
stopDrag();
if (foot._droptarget == "/foot1") {
foot._x = 237.0;
foot._y = 586.15;
if 
(arm._droptarget == "/arm1" && neck._droptarget == "/neck1" && foot._droptarget == "/foot1" && head._droptarget == "/head1" && legs._droptarget == "/leg1" && hand._droptarget == "/hand1"){
nextFrame();}
} else {
foot._x = 401.75;
foot._y = 64.25;

}

};
//
//

//
//

head.onPress = function() { 
head.startDrag();
};
head.onRelease = function() { 
stopDrag();
if (head._droptarget == "/head1") {
head._x = 237.0;
head._y = 570.4;
if 
(arm._droptarget == "/arm1" && neck._droptarget == "/neck1" && foot._droptarget == "/foot1" && head._droptarget == "/head1" && legs._droptarget == "/leg1" && hand._droptarget == "/hand1"){
nextFrame();}
} else {
head._x = 247.55;
head._y = 47.1;

}

};
//
//

//
//

legs.onPress = function() { 
legs.startDrag();
};
legs.onRelease = function() { 
stopDrag();
if (legs._droptarget == "/leg1") {
legs._x = 237.0;
legs._y = 539.6;
if 
(arm._droptarget == "/arm1" && neck._droptarget == "/neck1" && foot._droptarget == "/foot1" && head._droptarget == "/head1" && legs._droptarget == "/leg1" && hand._droptarget == "/hand1"){
nextFrame();}
} else {
legs._x = 286.45;
legs._y = 47.1;

}

};
//
//

//
//

hand.onPress = function() { 
hand.startDrag();
};
hand.onRelease = function() { 
stopDrag();
if (hand._droptarget == "/hand1") {
hand._x = 237.0;
hand._y = 617.1;
if 
(arm._droptarget == "/arm1" && neck._droptarget == "/neck1" && foot._droptarget == "/foot1" && head._droptarget == "/head1" && legs._droptarget == "/leg1" && hand._droptarget == "/hand1"){
nextFrame();}
} else {
hand._x = 523.3;
hand._y = 47.1;

}

};
//
//

Por kaotiko

0 de clabLevel



 

firefox
Citar            
MensajeEscrito el 12 Jul 2009 11:03 am
Cuando lees la película en un nivel, las llamadas a dropTarget cambiarán, por ejemplo la siguiente condición se cumplirá si ejecutas la película por sí sola:

Código ActionScript :

if(arm._droptarget == "/arm1"){

}


Pero si la lees en un nivel de otra película esa condición nunca se cumplirá ya que el droptarget no será con respecto a la raiz:

Código ActionScript :

//---La siguiente condición sí se cumplirá cuando la película se lea en el nivel 10
if(arm._droptarget == "_level10/arm1"){
 
}


Para evitar esto lo mejor que puedes hacer es crear una función que te separe el último elemento del droptarget y te lo devuelva, así puedes compararlo con el string que desees y te funcionará lo mismo si ejecutas la peli por si sola que si la lees en un nivel o dentro de un MovieClip. Esto es un ejemplo de la función que podrías utilizar:

Código ActionScript :

function giveMeDrop(drop:String):String{
   
   var index:Number = drop.lastIndexOf("/");   
   return ((index < 0) ? drop : drop.slice(index, drop.length))
   
}


Y la forma en que harías las condiciones sería la siguiente (pongo el mismo código tuyo):

Código ActionScript :

head.onRelease = function() {
   stopDrag();
   if (giveMeDrop(head._droptarget) == "/head1") {
      head._x = 237.0;
      head._y = 570.4;
      if (giveMeDrop(arm._droptarget) == "/arm1" && giveMeDrop(neck._droptarget) == "/neck1" && giveMeDrop(foot._droptarget) == "/foot1" && giveMeDrop(head._droptarget) == "/head1" && giveMeDrop(legs._droptarget) == "/leg1" && giveMeDrop(hand._droptarget) == "/hand1") {
         nextFrame();
      }
   } else {
      head._x = 247.55;
      head._y = 47.1;

   }
};

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.