I have some glitches in some drag and drop code I’m working with. I’ve modified someone else’s code to get the effect I need. The issue is with the following function:
myAnswers = [[1, 1], [2, 4], [3, 2], [1, 3], [3, 6], [1, 5]];
function doDrop(cardNum, categoryNum) {
for (i=1; i<7; i++) {
Q = _root.myAnswers[i-1][0];
A = _root.myAnswers[i-1][1];
//trace(Q+","+A);
if (_root[“a”+A].hitTest("_root.q"+Q)) {
//trace(_root[“a”+A].hitTest("_root.q"+Q));
_root.results_txt.text = “Correct”;
_root[“a”+A]._x = _root[“q”+Q]._x+15;
_root[“a”+A]._y = _root[“q”+Q]._y+15;
_root[“a”+A].enabled = false;
} else {
//trace(_root[“a”+A].hitTest("_root.q"+Q));
_root.results_txt.text = “Wrong”;
_root[“a”+A].enabled = true;
_root[“a”+A]._x = _root[“a”+A].stx;
_root[“a”+A]._y = _root[“a”+A].sty;
}
}
}
The array “myAnswers” tells which card goes to which category. But since I’m using a loop to access the array I don’t get the appropriate “correct” or “wrong” text displayed - the last item in the list is always displayed instead (and that is “wrong” until you get to the second to last card for some reason - shouldn’t it be the last card?). I could use some help fixing this function.
The test file is here:
http://www.tornedgedesign.com/_test/kirupa/drag_drop.zip