Hi Ludovic Mercier, I know this is probably more work, but maybe try writing the code in Actionscript 3. Below is a tutorial on how to make a puzzle with AS3. https://code.tutsplus.com/tutorials/create-a-drag-and-drop-puzzle-in-actionscript-30--active-2920 If you don't want to do that, here is code from a puzzle game I built in AS2 years ago. I put in comments to try to explain the code. Hopefully one of these suggestions helps you out. youWin._visible = false; checkContainer.check1._visible = false; checkContainer.check2._visible = false; checkContainer.check3._visible = false; checkContainer.check4._visible = false; checkContainer.check5._visible = false; checkContainer.check6._visible = false; checkContainer.check7._visible = false; checkContainer.check8._visible = false; /*****************************************/ function dragSetup1(clip, targ) { clip.onPress = function() { startDrag(this); this.beingDragged = true; }; clip.onRelease = clip.onReleaseOutside = function () { stopDrag(); this.beingDragged = false; if (eval(this._droptarget) == targ) { this.onTarget = true; _root.targ.gotoAndStop(2); _root.answer1.gotoAndPlay(2); checkContainer.check1._visible = true; if (answer1._currentframe == 2 && answer2._currentframe == 8 && answer3._currentframe == 8 && answer4._currentframe == 8 && answer5._currentframe == 8 && answer6._currentframe == 8 && answer7._currentframe == 8 && answer8._currentframe == 8) { youWin._visible = true; } } else { this.onTarget = false; _root.targ.gotoAndStop(1); } }; //the variables below will store the clips starting position clip.myHomeX = clip._x; clip.myHomeY = clip._y; //the variables below will store the clips end position clip.myFinalX = targ._x; clip.myFinalY = targ._y; clip.onEnterFrame = function() { //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged) // then move the MC back to its original starting point (with a smooth motion)" if (!this.beingDragged && !this.onTarget) { this._x -= (this._x - this.myHomeX) / 5; this._y -= (this._y - this.myHomeY) / 5; //if the circle is dropped on any part of the target it slides to the center of the target } else if (!this.beingDragged && this.onTarget) { this._x -= (this._x - this.myFinalX) / 5; this._y -= (this._y - this.myFinalY) / 5; } }; } dragSetup1(answer1,target1); /*****************************************/ /*****************************************/ function dragSetup2(clip, targ) { clip.onPress = function() { startDrag(this); this.beingDragged = true; }; clip.onRelease = clip.onReleaseOutside = function () { stopDrag(); this.beingDragged = false; if (eval(this._droptarget) == targ) { this.onTarget = true; _root.targ.gotoAndStop(2); _root.answer2.gotoAndPlay(2); checkContainer.check2._visible = true; if (answer1._currentframe == 8 && answer2._currentframe == 2 && answer3._currentframe == 8 && answer4._currentframe == 8 && answer5._currentframe == 8 && answer6._currentframe == 8 && answer7._currentframe == 8 && answer8._currentframe == 8) { youWin._visible = true; } } else { this.onTarget = false; _root.targ.gotoAndStop(1); } }; //the variables below will store the clips starting position clip.myHomeX = clip._x; clip.myHomeY = clip._y; //the variables below will store the clips end position clip.myFinalX = targ._x; clip.myFinalY = targ._y; clip.onEnterFrame = function() { //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged) // then move the MC back to its original starting point (with a smooth motion)" if (!this.beingDragged && !this.onTarget) { this._x -= (this._x - this.myHomeX) / 5; this._y -= (this._y - this.myHomeY) / 5; //if the circle is dropped on any part of the target it slides to the center of the target } else if (!this.beingDragged && this.onTarget) { this._x -= (this._x - this.myFinalX) / 5; this._y -= (this._y - this.myFinalY) / 5; } }; } dragSetup2(answer2,target2); /*****************************************/ /*****************************************/ function dragSetup3(clip, targ) { clip.onPress = function() { startDrag(this); this.beingDragged = true; }; clip.onRelease = clip.onReleaseOutside = function () { stopDrag(); this.beingDragged = false; if (eval(this._droptarget) == targ) { this.onTarget = true; _root.targ.gotoAndStop(2); _root.answer3.gotoAndPlay(2); checkContainer.check3._visible = true; if (answer1._currentframe == 8 && answer2._currentframe == 8 && answer3._currentframe == 2 && answer4._currentframe == 8 && answer5._currentframe == 8 && answer6._currentframe == 8 && answer7._currentframe == 8 && answer8._currentframe == 8) { youWin._visible = true; } } else { this.onTarget = false; //_root.targ.gotoAndStop(1); } }; //the variables below will store the clips starting position clip.myHomeX = clip._x; clip.myHomeY = clip._y; //the variables below will store the clips end position clip.myFinalX = targ._x; clip.myFinalY = targ._y; clip.onEnterFrame = function() { //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged) // then move the MC back to its original starting point (with a smooth motion)" if (!this.beingDragged && !this.onTarget) { this._x -= (this._x - this.myHomeX) / 5; this._y -= (this._y - this.myHomeY) / 5; //if the circle is dropped on any part of the target it slides to the center of the target } else if (!this.beingDragged && this.onTarget) { this._x -= (this._x - this.myFinalX) / 5; this._y -= (this._y - this.myFinalY) / 5; } }; } dragSetup3(answer3,target3); /*****************************************/ /*****************************************/ function dragSetup4(clip, targ) { clip.onPress = function() { startDrag(this); this.beingDragged = true; }; clip.onRelease = clip.onReleaseOutside = function () { stopDrag(); this.beingDragged = false; if (eval(this._droptarget) == targ) { this.onTarget = true; _root.targ.gotoAndStop(2); _root.answer4.gotoAndPlay(2); checkContainer.check4._visible = true; if (answer1._currentframe == 8 && answer2._currentframe == 8 && answer3._currentframe == 8 && answer4._currentframe == 2 && answer5._currentframe == 8 && answer6._currentframe == 8 && answer7._currentframe == 8 && answer8._currentframe == 8) { youWin._visible = true; } } else { this.onTarget = false; _root.targ.gotoAndStop(1); } }; //the variables below will store the clips starting position clip.myHomeX = clip._x; clip.myHomeY = clip._y; //the variables below will store the clips end position clip.myFinalX = targ._x; clip.myFinalY = targ._y; clip.onEnterFrame = function() { //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged) // then move the MC back to its original starting point (with a smooth motion)" if (!this.beingDragged && !this.onTarget) { this._x -= (this._x - this.myHomeX) / 5; this._y -= (this._y - this.myHomeY) / 5; //if the circle is dropped on any part of the target it slides to the center of the target } else if (!this.beingDragged && this.onTarget) { this._x -= (this._x - this.myFinalX) / 5; this._y -= (this._y - this.myFinalY) / 5; } }; } dragSetup4(answer4,target4); /*****************************************/ /*****************************************/ function dragSetup5(clip, targ) { clip.onPress = function() { startDrag(this); this.beingDragged = true; }; clip.onRelease = clip.onReleaseOutside = function () { stopDrag(); this.beingDragged = false; if (eval(this._droptarget) == targ) { this.onTarget = true; _root.targ.gotoAndStop(2); _root.answer5.gotoAndPlay(2); checkContainer.check5._visible = true; if (answer1._currentframe == 8 && answer2._currentframe == 8 && answer3._currentframe == 8 && answer4._currentframe == 8 && answer5._currentframe == 2 && answer6._currentframe == 8 && answer7._currentframe == 8 && answer8._currentframe == 8) { youWin._visible = true; } } else { this.onTarget = false; _root.targ.gotoAndStop(1); } }; //the variables below will store the clips starting position clip.myHomeX = clip._x; clip.myHomeY = clip._y; //the variables below will store the clips end position clip.myFinalX = targ._x; clip.myFinalY = targ._y; clip.onEnterFrame = function() { //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged) // then move the MC back to its original starting point (with a smooth motion)" if (!this.beingDragged && !this.onTarget) { this._x -= (this._x - this.myHomeX) / 5; this._y -= (this._y - this.myHomeY) / 5; //if the circle is dropped on any part of the target it slides to the center of the target } else if (!this.beingDragged && this.onTarget) { this._x -= (this._x - this.myFinalX) / 5; this._y -= (this._y - this.myFinalY) / 5; } }; } dragSetup5(answer5,target5); /*****************************************/ /*****************************************/ function dragSetup6(clip, targ) { clip.onPress = function() { startDrag(this); this.beingDragged = true; }; clip.onRelease = clip.onReleaseOutside = function () { stopDrag(); this.beingDragged = false; if (eval(this._droptarget) == targ) { this.onTarget = true; _root.targ.gotoAndStop(2); _root.answer6.gotoAndPlay(2); checkContainer.check6._visible = true; if (answer1._currentframe == 8 && answer2._currentframe == 8 && answer3._currentframe == 8 && answer4._currentframe == 8 && answer5._currentframe == 8 && answer6._currentframe == 2 && answer7._currentframe == 8 && answer8._currentframe == 8) { youWin._visible = true; } } else { this.onTarget = false; _root.targ.gotoAndStop(1); } }; //the variables below will store the clips starting position clip.myHomeX = clip._x; clip.myHomeY = clip._y; //the variables below will store the clips end position clip.myFinalX = targ._x; clip.myFinalY = targ._y; clip.onEnterFrame = function() { //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged) // then move the MC back to its original starting point (with a smooth motion)" if (!this.beingDragged && !this.onTarget) { this._x -= (this._x - this.myHomeX) / 5; this._y -= (this._y - this.myHomeY) / 5; //if the circle is dropped on any part of the target it slides to the center of the target } else if (!this.beingDragged && this.onTarget) { this._x -= (this._x - this.myFinalX) / 5; this._y -= (this._y - this.myFinalY) / 5; } }; } dragSetup6(answer6,target6); /*****************************************/ /*****************************************/ function dragSetup7(clip, targ) { clip.onPress = function() { startDrag(this); this.beingDragged = true; }; clip.onRelease = clip.onReleaseOutside = function () { stopDrag(); this.beingDragged = false; if (eval(this._droptarget) == targ) { this.onTarget = true; _root.targ.gotoAndStop(2); _root.answer7.gotoAndPlay(2); checkContainer.check7._visible = true; if (answer1._currentframe == 8 && answer2._currentframe == 8 && answer3._currentframe == 8 && answer4._currentframe == 8 && answer5._currentframe == 8 && answer6._currentframe == 8 && answer7._currentframe == 2 && answer8._currentframe == 8) { youWin._visible = true; } } else { this.onTarget = false; _root.targ.gotoAndStop(1); } }; //the variables below will store the clips starting position clip.myHomeX = clip._x; clip.myHomeY = clip._y; //the variables below will store the clips end position clip.myFinalX = targ._x; clip.myFinalY = targ._y; clip.onEnterFrame = function() { //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged) // then move the MC back to its original starting point (with a smooth motion)" if (!this.beingDragged && !this.onTarget) { this._x -= (this._x - this.myHomeX) / 5; this._y -= (this._y - this.myHomeY) / 5; //if the circle is dropped on any part of the target it slides to the center of the target } else if (!this.beingDragged && this.onTarget) { this._x -= (this._x - this.myFinalX) / 5; this._y -= (this._y - this.myFinalY) / 5; } }; } dragSetup7(answer7,target7); /*****************************************/ /*****************************************/ function dragSetup8(clip, targ) { clip.onPress = function() { startDrag(this); this.beingDragged = true; }; clip.onRelease = clip.onReleaseOutside = function () { stopDrag(); this.beingDragged = false; if (eval(this._droptarget) == targ) { this.onTarget = true; _root.targ.gotoAndStop(2); _root.answer8.gotoAndPlay(2); checkContainer.check8._visible = true; if (answer1._currentframe == 8 && answer2._currentframe == 8 && answer3._currentframe == 8 && answer4._currentframe == 8 && answer5._currentframe == 8 && answer6._currentframe == 8 && answer7._currentframe == 8 && answer8._currentframe == 2) { youWin._visible = true; } } else { this.onTarget = false; //_root.targ.gotoAndStop(1); } }; //the variables below will store the clips starting position clip.myHomeX = clip._x; clip.myHomeY = clip._y; //the variables below will store the clips end position clip.myFinalX = targ._x; clip.myFinalY = targ._y; clip.onEnterFrame = function() { //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged) // then move the MC back to its original starting point (with a smooth motion)" if (!this.beingDragged && !this.onTarget) { this._x -= (this._x - this.myHomeX) / 5; this._y -= (this._y - this.myHomeY) / 5; //if the circle is dropped on any part of the target it slides to the center of the target } else if (!this.beingDragged && this.onTarget) { this._x -= (this._x - this.myFinalX) / 5; this._y -= (this._y - this.myFinalY) / 5; } }; } dragSetup8(answer8,target8); /*****************************************/ /*if (theChosenOne == 1 && theChosenTwo == 2 && theChosenThree == 3 && theChosenFour == 4 && theChosenFive == 5 && theChosenSix == 6 && theChosenSeven == 7 && theChosenEight == 8) { trace("what up"); youWin._visible = true; } */ /*if (answer1._currentframe == 2) { trace("what up"); youWin._visible = true; } */
... View more