Drag and drop z order

Hi there

I’m new to the forum so firstly helllo

I’m trying to create a reasonable simple drag and drop animation when the user can grab different coloured square around the stage.

The problem is I want to have the animation so when they click on eack individual square it pops to the top of the z order (the forground) and then on release returns to it’s original postion in the animations z-order (layers)

Any ideas on how to code this ?

I’ve just found the swap depth tutorial on this which explains some of my problem but not how to make the square return to their original z value once released. Any ideas on how to do that ?

think it goes something like this???

on (press) {
startDrag(this);
this.swapDepths(100);
}
on (release) {
stopDrag();
if (this._droptarget=="/target2") {
setProperty(this, _x, 444.8);
setProperty(this, _y, 249.5);
} else {
setProperty(this, _x, 341.5); --> origin position
setProperty(this, _y, 193.0); -->Origin position
}
}

cheers i’ll give that a try :slight_smile:

do I need to add anything else in to make it work ?

basically what u want is that when it drags and chooses a wrong answer, its goes back to its original position right…

If it is the case, then the above codes should be correct…