Drag Drop Layers

Let me start off by describing my scenario and then the problem I have to overcome.

So what im trying to accomplish is prob really easy, but Im having a tough time figuring it out. So there is a bunch of objects that can be dragged around on the stage, and have a target drop zone that if you drop it in the zone, it snaps to the zone.

What I would like to accomplish is that if I have one object , drag it to the zone then that current object shows up on the top layer. So when I drag a new object to the same drop zone, the newest object dragged to the zone is the top layer.

One simple solution would be to position the objects on different layers in the timeline but would just somewhat work.

Here is some of the code ive been working with:

The Draggable Objects


on (press){
    _root.piece1.startDrag();
}

on (release){
    _root.piece1.stopDrag();
    if (eval(_root.piece1._droptarget) == _root.drop1) {
        _root.piece1._x=_root.drop1._x;
        _root.piece1._y=_root.drop1._y;
        _root.piece1correct="True";
    }else{
        _root.piece1correct="False";
    }
}


---------- PIECE 2

on (press){
    _root.piece2.startDrag();
}

on (release){
    _root.piece2.stopDrag();
    if (eval(_root.piece2._droptarget) == _root.drop1) {
        _root.piece2._x=_root.drop1._x;
        _root.piece2._y=_root.drop1._y;
        _root.piece2correct="True";
    }else{
        _root.piece2correct="False";
    }
}

Thanks for anyone who gives this some thought. :slight_smile: