Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 1 of 1

Thread: AS3 Multiple Drop Targets (Again)

  1. #1

    AS3 Multiple Drop Targets (Again)

    Hi, this question has been asked by someone else using similar code a while ago at http://www.kirupa.com/forum/showthre...ight=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).

    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:

    HTML Code:
    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 {
        reply_txt.text = "";
        startX = event.target.x;
        startY = event.target.y;
    function drop(event:MouseEvent):void {
        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;
        } else {
            reply_txt.text = "Try Again!";
            event.target.x = startX;
            event.target.y = startY;
        if(counter == 3){
            reply_txt.text = "Finished!";
    E.buttonMode = true;
    V.buttonMode = true;
    E2.buttonMode = true;
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About kirupa.com Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012