AS2 Drag & Drop Game: How to reveal a 'congratulations' message
Hi all.
I'm nearing the end of a drag & drop game that contains 12 objects with 12 targets. I've pasted an example of how my drag & drop works. I'm trying to figure out how to display (or got to a frame) that displays a congratulations message with an 'If' (something that knows when all of my objects are all locked into the correct coordinates).
Thanks in advance! ![]()
Example of how drag & drop on on object/target is written
// DRAG OBJECT NAME: 'drag4_mc' TARGET NAME 'drop_mc'
drag4_mc.onPress = function() {
startDrag(this);
};
drag4_mc.onRelease = drag4_mc.onReleaseOutside=function () {
stopDrag();
if (this._droptarget == "/drop_mc") {
this.onTarget = true;
_root.test1_mc.gotoAndStop(2);
var isLocked = true;
} else {
this.onTarget = false;
_root.drop_mc.gotoAndStop(1);
}
};
//the variables below will store the clips starting position
drag4_mc.myHomeX=drag4_mc._x;
drag4_mc.myHomeY=drag4_mc._y;
//the variables below will store the clips end position
drag4_mc.myFinalX = 726.10;
drag4_mc.myFinalY = 437.10;
drag4_mc.onMouseDown = function() {
//this variable tells us if the mouse is up or down
mousePressed = true;
};
drag4_mc.onMouseUp = function() {
mousePressed = false;
};
drag4_mc.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 (mousePressed == false && this.onTarget == false) {
this._x -= (this._x-this.myHomeX)/5;
this._y -= (this._y-this.myHomeY)/5;
//if the object is dropped on any part of the target it slides to the center of the target
} else if (mousePressed == false && this.onTarget == true) {
this._x -= (this._x-this.myFinalX)/5;
this._y -= (this._y-this.myFinalY)/5;
}
};
