# AS3 Multiple Drop Targets (Again)

**URL:** <https://forum.kirupa.com/t/as3-multiple-drop-targets-again/303102>\
**Category:** flash\
**Created:** [January 14, 2010, 1:21am UTC](https://forum.kirupa.com/t/as3-multiple-drop-targets-again/303102 "2010-01-14T01:21:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![atype](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@atype](https://forum.kirupa.com/u/atype)\
**Post date:** [January 14, 2010, 1:21am UTC](https://forum.kirupa.com/t/as3-multiple-drop-targets-again/303102/1 "2010-01-14T01:21:24Z")

</div>

Hi, this question has been asked by someone else using similar code a while ago at [http://www.kirupa.com/forum/showthread.php?t=308543&highlight=drag+drop](http://www.kirupa.com/forum/showthread.php?t=308543&highlight=drag+drop) but I still can’t get it to work, so I have simplified my version and attached the source files. (They are based on a tutorial from [here](http://monkeyflash.com/tutorials/flash-drag-and-drop/)).

It is a word puzzle where I am having trouble getting a letter that is duplicated to drop onto either position (i.e. in the word “EVE” I can get the first “E” to drop on the first target and the last “E” onto the last target, but I don’t know how to get either “E” to fall on either the first or second target).

Can anyone help out?

The code:

```auto

var startX:Number;
var startY:Number;
var counter:Number = 0;

E.addEventListener(MouseEvent.MOUSE_DOWN, pickup);
E.addEventListener(MouseEvent.MOUSE_UP, drop);
V.addEventListener(MouseEvent.MOUSE_DOWN, pickup);
V.addEventListener(MouseEvent.MOUSE_UP, drop);
E2.addEventListener(MouseEvent.MOUSE_DOWN, pickup);
E2.addEventListener(MouseEvent.MOUSE_UP, drop);

function pickup(event:MouseEvent):void {
    event.target.startDrag(true);
    reply_txt.text = "";
    event.target.parent.addChild(event.target);
    startX = event.target.x;
    startY = event.target.y;
}
function drop(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String = "target" + event.target.name;
    var myTarget:DisplayObject = getChildByName(myTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
        reply_txt.text = "Correct!";
        event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickup);
        event.target.removeEventListener(MouseEvent.MOUSE_UP, drop);
        event.target.buttonMode = false;
        event.target.x = myTarget.x;
        event.target.y = myTarget.y;
        counter++;
    } else {
        reply_txt.text = "Try Again!";
        event.target.x = startX;
        event.target.y = startY;
    }
    if(counter == 3){
        reply_txt.text = "Finished!";
        this.play();
    }

}

E.buttonMode = true;
V.buttonMode = true;
E2.buttonMode = true;

```
