9 Replies Latest reply on Mar 10, 2013 2:55 PM by Siderz95

    How do you drag and drop to multiple targets?

    Siderz95 Level 1

      I know this has been asked a lot, but all the threads I've looked at seem to make it too complicated/are for AS3.

       

      I'm making a drag and drop game which involves mixing and matching, so I want it so you can drag one object and decide on which side that object should go on. I've also added simple click sounds for when you drag and drop. Here's the code I've got:

       

      on(press) {

                _root.mySound2.start(0,0);

      startDrag(this);

      }

      on(release) {

      stopDrag();

      if (this._droptarget == "/target") {

                _root.mySound.start(0,0);

      this._x = _root. target._x;

      this._y = _root. target._y;

       

       

      }

      else{

      this._x = 423.95;

      this._y = 109.45;

       

       

      }

       

       

      }

       

      I was hoping that I could simply copy and paste "if (this._droptarget == "/target") {" below the "  _root.mySound.start(0,0);" and just replace 'target' with 'target2', but this doesn't work.

       

      I'd rather modify the code I've got rather than introduce a new string (Is 'string' a correct term?), but if someone can get me a simple to read string which includes sound as well, I will be happy to use it.