Skip to main content
Known Participant
July 25, 2009
Answered

puzzling puzzle problem

  • July 25, 2009
  • 3 replies
  • 786 views

Hey all

So I have a puzzle that doesn't want to work properly. I have it setup so when all six pieces are dragged onto their respective spots, the movie goes to frame 2, but when I drag all the pieces properly and the scores add up to 6, the action of going to frame 2 doesn't occur, but if I pull a piece off, and the score equals 5 the action occurs!?!?!?!?!?!

There are 6 pieces named tl, tm, tr, bl, bm, br and those get dragged onto their 6 respective mcs (drag_tl etc.).

I have no idea why this is happening. Any help would be appreciated.

Thanks

Here's the link: superbean_puzzle

...one more thing, is there a way to make the link disply at 100% instead of full screen?

Thanks some more

stop();


// Cursor //
onMouseMove = function () {
     updateAfterEvent();
}
onEnterFrame = function() {
     counter.text = ((scoretl + scoretm + scoretr + scorebl + scorebm + scorebr) + "/6");
     if (scoretl + scoretm + scoretr + scorebl + scorebm + scorebr == 6) {
          gotoAndPlay(2);
          }
     Mouse.hide();
     curs._x = _xmouse;
     curs._y = _ymouse;
};

onMouseDown = function() {
     curs.gotoAndStop(2);
};
onMouseUp = function() {
     curs.gotoAndStop(1);
};

pieceArr = Array()
pieceArr[0] = "tl";
pieceArr[1] = "tm";
pieceArr[2] = "tr";
pieceArr[3] = "bl";
pieceArr[4] = "bm";
pieceArr[5] = "br";

dragArr = Array()
dragArr[0] = "drag_tl";
dragArr[1] = "drag_tm";
dragArr[2] = "drag_tr";
dragArr[3] = "drag_bl";
dragArr[4] = "drag_bm";
dragArr[5] = "drag_br";

var scoretl = 0;
var scoretm = 0;
var scoretr = 0;
var scorebl = 0;
var scorebm = 0;
var scorebr = 0;

for(i=0; i<pieceArr.length; i++)
(_root[pieceArr]).onPress = function() {
     startDrag(this);
};
for(i=0; i<pieceArr.length; i++)
(_root[pieceArr]).onRelease = function() {
     stopDrag();
     checkTarget(this);
};

function checkTarget(drag) {
     if(tl.hitTest(drag_tl)) {
          setProperty(tl,_x, 256);
          setProperty(tl,_y, 186);
               if (scoretl == 0) {
                    scoretl = 1;
               }
     } else {scoretl = 0}
          //trace("1 " + scoretl);
     if(tm.hitTest(drag_tm)) {
          setProperty(tm,_x, 353);
          setProperty(tm,_y, 203);
               if (scoretm == 0) {
                    scoretm = 1;
               }
     } else {scoretm = 0}
          //trace(scoretm);
     if(tr.hitTest(drag_tr)) {
          setProperty(tr,_x, 463);
          setProperty(tr,_y, 203);
               if (scoretr == 0) {
                    scoretr = 1;
               }
     } else {scoretr = 0}
          //trace(scoretr);
     if(bl.hitTest(drag_bl)) {
          setProperty(bl,_x, 257);
          setProperty(bl,_y, 280.5);
               if (scorebl == 0) {
                    scorebl = 1;
               }
     } else {scorebl = 0}
          //trace(scorebl);
     if(bm.hitTest(drag_bm)) {
          setProperty(bm,_x, 370);
          setProperty(bm,_y, 298);
               if (scorebm == 0) {
                    scorebm = 1;
               }
     } else {scorebm = 0}
          //trace(scorebm);
     if(br.hitTest(drag_br)) {
          setProperty(br,_x, 479.5);
          setProperty(br,_y, 297.5);
               if (scorebr == 0) {
                    scorebr = 1;
               }
     } else {scorebr = 0}
          //trace(scorebr);
};
This topic has been closed for replies.
Correct answer dalcde

try _root.gotoAndStop(2), or _root.nextFrame().

3 replies

Known Participant
July 26, 2009

kglad: Thanks! I didn't realise I had to get rid of the "_root" when taking "" off mc indices.

dalcde: Thanks! The _root.nextFrame got it!! I don't know why though..... It kinda bugs me

Thanks again guys!

kglad
Community Expert
Community Expert
July 26, 2009

you're welcome.

dalcde
dalcdeCorrect answer
Inspiring
July 25, 2009

try _root.gotoAndStop(2), or _root.nextFrame().

kglad
Community Expert
Community Expert
July 25, 2009

remove the quotes from the array elements in both arrays.

Known Participant
July 25, 2009

Thanks kglad.

If I do that though, then my mc pieces don't drag... ?

kglad
Community Expert
Community Expert
July 25, 2009

in some places you use _root[array] to resolve those strings to movieclips and that would work if you did it throughout.  or just use the array element without the _root[] to use elements that are movieclips.