Skip to main content
Participant
September 19, 2018
Answered

multiple "drag and drop"

  • September 19, 2018
  • 1 reply
  • 403 views

HI, i have a problem with drag and drop programming in animate actionscript 3

i have 2 movieclips "red1" and "red2"

and the goal is to drag any of them to the targerts "target1" and "target2" that

the specific drag of the movieclip to its target does not matter (red 1 can be dragged to target2, and vice versa)

how do i do that?

thank you!

    This topic has been closed for replies.
    Correct answer kglad

    i put it in the comment above.

    it works perfectly fine with 1 object and target, now i try to make it with 2


    as mentioned in message 1, you should be using currentTarget instead of target.

    once your do that, what's the problem?

    1 reply

    kglad
    Community Expert
    Community Expert
    September 19, 2018

    add mousedown and mouseup listeners to both

    in the mousedown listener start a loop that assigns the currentTarget's x and y properties to mouseX and mouseY.

    in the mouse up listener terminate the loop and check for a hit with your drop target.

    Participant
    September 19, 2018

    kglad yes that part i understood, i have sucsessfully created drag and drop with one object and one target (when object dropped on target, it stays, and when object dropped anywhere else, it returns to original position)

    now i try to do the same with 2 identical objects, and 2 targets, and for my purpose it shouldn't matter what object i drag to what target, when i drag the object to any target, it should stay there, and then drag the second object to the remaining target.

    thank you

    kglad
    Community Expert
    Community Expert
    September 19, 2018

    what's the problem?