5 Replies Latest reply on Feb 4, 2008 7:10 PM by Rothrock

    Drag n drop stuff

      Hi all.
      I have this weird behavior regarding drag n drop stuff.
      The scenario:
      MC1 is on layer1.
      MC2 is on layer2.
      You drag MC1 and drop it on MC2.

      Guess what? MC1 still stick to the mouse. MC1 still follow the mouse eventhough you've release the mouse. Is this normal? What should I do be able to drop it on any MC on the stage regardless of their layer on the timeline?

      Below is the code on the timeline (it's a normal,non-fancy code really).
      Thanks in advance guys.
        • 1. Re: Drag n drop stuff
          robdillon Most Valuable Participant
          I'm not sure if I correctly understand the problem but... If you are dragging one clip, and it moves under another clip and that second clip is also referenced by actionscript then any new action will be received by the clip that is on top.

          If this is what is going on, then you could swap depths so that the clip that you are moving remains on top. Something like this:
          • 2. Re: Drag n drop stuff
            zoldol Level 1
            Question: If that's the case ("... then any new action will be received by the clip that is on top"), then why Cl.onRelease function doesn't stop the dragging of MC1 (in this case H1)? stopDrag will release anything that's being dragged, right?

            But, I've modified a bit the solution that you gave me. I used


            instead of


            since MC1 could be dropped onto any other MCs (which I don't know which one beforehand) on the stage.

            • 3. Re: Drag n drop stuff
              Rothrock Level 5
              Don't know if this will help, but this is one of the most often overlooked movieclip/button events: onReleaseOutside.

              If you release the mouse, but it is over some other clip/button which also has defined clip events, the original item will not know that you have released it because it has been "release outside." This is one of the things I always test in any flash file I am given and often you get the "stuck to the mouse with no way to get it unstuck" problem.

              So just define an onReleaseOutside handler that does whatever you would like to happen in that case and you should be good as gold.
              • 4. Re: Drag n drop stuff
                zoldol Level 1
                Yes it does. Thanks a lot. Now I can sleep with peace.

                Thanks guys.
                • 5. Re: Drag n drop stuff
                  Rothrock Level 5
                  Glad that worked out for you. Pleasant dreams!