# Simple drag and drop problem in AS 2

**URL:** <https://forum.kirupa.com/t/simple-drag-and-drop-problem-in-as-2/268748>\
**Category:** flash\
**Created:** [August 18, 2008, 12:48pm UTC](https://forum.kirupa.com/t/simple-drag-and-drop-problem-in-as-2/268748 "2008-08-18T12:48:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bonwhis](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@Bonwhis](https://forum.kirupa.com/u/Bonwhis)\
**Post date:** [August 18, 2008, 12:48pm UTC](https://forum.kirupa.com/t/simple-drag-and-drop-problem-in-as-2/268748/1 "2008-08-18T12:48:36Z")

</div>

Hi

I have used the following tutorial to create a drap and drop game…

[http://www.monkeyflash.com/flash/drag-and-drop-2/](http://www.monkeyflash.com/flash/drag-and-drop-2/)

Source file can be downloaded here:

[http://www.monkeyflash.com/files/dragdrop2.zip](http://www.monkeyflash.com/files/dragdrop2.zip)

I need the objects to snap into the center of the targets upon release, how do I do that?  
I have tried but my lack flash experience is a problem…

```auto

var counter:Number = 0;
var woodSound:Sound = new Sound();
woodSound.attachSound("woodblock");

onEnterFrame = function():Void{
    if(counter == 4){
        reply_txt.text = "Congrats, you're finished!";
    }
};

square_mc.onPress = function():Void {
    this.startDrag(true);
    reply_txt.text = "";
    this.swapDepths(this.getNextHighestDepth());
    xstart = this._x;
    ystart = this._y;
};
square_mc.onRelease = function():Void {
    this.stopDrag();
    if (eval(this._droptarget) == squareTarget_mc) {
        reply_txt.text="You got it!";
        this.enabled = false;
        counter++;
        woodSound.start(0,1);
    }
    else{
        reply_txt.text="No, keep trying!";
        this._x = xstart;
        this._y = ystart;
    }
};

```

Thank you very much…

-Bonwhis
