Skip to main content
December 7, 2009
Answered

If Multiple Hittests equal true, go to and play next frame

  • December 7, 2009
  • 1 reply
  • 451 views

Hi All,

I am trying to finish up a project and run into this problem, right now I am trying to create a drag and drop game and on the last game you can drop

parts into the others, what I want to happen is that when all are in the correct spot gotoandplay next frame. This is my current code,

Thanks

if(one_mc._droptarget=="/onedef_mc" && two_mc._droptarget=="/twodef_mc" && three_mc._droptarget=="/threedef_mc" &&
four_mc._droptarget=="/fourdef_mc" && five_mc._droptarget=="/fivedef_mc" && six_mc._droptarget=="/sixdef_mc" &&
cave_mc._droptarget=="/cavedef_mc" && eight_mc._droptarget=="/eightdef_mc" && nine_mc._droptarget=="/ninedef_mc" &&
ten_mc._droptarget=="/tendef_mc" && eleven_mc._droptarget=="/elevendef_mc" && twelve_mc._droptarget=="/twelvedef_mc");

this is the if statement, im just not sure how to implement the gotoandplay...

Does this make sense?

Thanks

This topic has been closed for replies.
Correct answer kglad

Sorry I misenterpreted, I thought you were asking if you thought I should be using that,

I dont actually have the check code,

I think thats why it's not working...

Do you think you could post it?

Right now I just have these hittest checks: Here is the check for one

one_mc.onPress = function()
{
one_mc.startDrag();
};
one_mc.onRelease = function()
{
if(one_mc._droptarget=="/onedef_mc")
{
  // align Sprite3
  one_mc._x = onedef_mc._x + (onedef_mc._width-one_mc._width)/2;
  one_mc._y = onedef_mc._y + (onedef_mc._height-one_mc._height)/2;
  one_mc.gotoAndPlay("success");
 
 
} else {
  (one_mc._droptarget=="/onedef_mc")
{
  // align Sprite3
  one_mc._x = onewrong_mc._x + (onewrong_mc._width-one_mc._width)/2;
  one_mc._y = onewrong_mc._y + (onewrong_mc._height-one_mc._height)/2;
  onedef_mc.gotoAndStop("fail");
};
};
one_mc.stopDrag();
};

Is that what you mean? Sorry it's such a mess


if you don't have code to check if all the movieclips have been dropped on their targets, there's no way that code can work.

use something like:


one_mc.onPress = function()
{
one_mc.startDrag();
};
one_mc.onRelease = function()
{

checkF();
if(one_mc._droptarget=="/onedef_mc")
{
  // align Sprite3
  one_mc._x = onedef_mc._x + (onedef_mc._width-one_mc._width)/2;
  one_mc._y = onedef_mc._y + (onedef_mc._height-one_mc._height)/2;
  one_mc.gotoAndPlay("success");
 
  // the code in italics doesn't look right
} else {
  (one_mc._droptarget=="/onedef_mc")
{
  // align Sprite3
  one_mc._x = onewrong_mc._x + (onewrong_mc._width-one_mc._width)/2;
  one_mc._y = onewrong_mc._y + (onewrong_mc._height-one_mc._height)/2;
  onedef_mc.gotoAndStop("fail");
};


};
one_mc.stopDrag();
};

function checkF(){

if(one_mc._droptarget=="/onedef_mc" && two_mc._droptarget=="/twodef_mc" && three_mc._droptarget=="/threedef_mc" &&
four_mc._droptarget=="/fourdef_mc" && five_mc._droptarget=="/fivedef_mc" && six_mc._droptarget=="/sixdef_mc" &&
cave_mc._droptarget=="/cavedef_mc" && eight_mc._droptarget=="/eightdef_mc" && nine_mc._droptarget=="/ninedef_mc" &&
ten_mc._droptarget=="/tendef_mc" && eleven_mc._droptarget=="/elevendef_mc" && twelve_mc._droptarget=="/twelvedef_mc"){

gotoAndPlay(_currentframe+1);

}

}

1 reply

kglad
Community Expert
Community Expert
December 7, 2009
the actionscript is ok.  whether is makes sense or not for you situation can't be determined from the code.  but assuming your want to check if all twelve of those movieclips have been dropped onto those corresponding "def" movieclips, use:

if(one_mc._droptarget=="/onedef_mc" && two_mc._droptarget=="/twodef_mc" && three_mc._droptarget=="/threedef_mc" &&
four_mc._droptarget=="/fourdef_mc" && five_mc._droptarget=="/fivedef_mc" && six_mc._droptarget=="/sixdef_mc" &&
cave_mc._droptarget=="/cavedef_mc" && eight_mc._droptarget=="/eightdef_mc" && nine_mc._droptarget=="/ninedef_mc" &&
ten_mc._droptarget=="/tendef_mc" && eleven_mc._droptarget=="/elevendef_mc" && twelve_mc._droptarget=="/twelvedef_mc"){

gotoAndPlay(_currentframe+1);

}

December 7, 2009

I thought that it go something like that, and yes thats true about the def, however when I run this I don't get any errors,

but it doesn't work properly, meaning that there is no frame change,
Would it help if i uploaded the FLA?

kglad
Community Expert
Community Expert
December 7, 2009

are you checking that conditional repeatedly?