1 Reply Latest reply on Jul 3, 2014 8:00 AM by kglad

    drag and drop duplicates and swap depth problem

    missana

      I have some drag and drop mc's that I want to duplicate but also to swap depth between them and also to stay bellow the item that are assign, the problem is that I used the code for swap depth but because it has " getNextHighestDepth " in it, only the first one is going where is suppose to go, the others stay at the top and if I click on the first one for the second time it stays on top and dosen't go under the item that I want. The drag and drop mc's are posted bellow the item. I also tried a different approach by trying to "tell them" where to go, but they don't duplicate anymore. How can I make it happen or what I'm doing wrong? Thank you so much for taking the time to help me.


      Here is the first code:


      var num = 0;

      DDD2.onPress = function ()

      {

          ++num;

          duplicateMovieClip(DDD2, "DDD2" + num, _root.getNextHighestDepth());

          _root["DDD2" + num].startDrag();

      };

       

       

      DDD2.onReleaseOutside = function ()

      {

          stopDrag ();

      };

       

       

      And here is the second code but they won't duplicate anymore:

       

      var num = 0;

      DDD2.onPress = function ()

      {

          ++num;

          duplicateMovieClip(DDD2, "DDD2" + num, _root.swapDepths(-15173));

          _root["DDD2" + num].startDrag();

      };

       

       

      DDD2.onReleaseOutside = function ()

      {

          stopDrag ();

      };

        • 1. Re: drag and drop duplicates and swap depth problem
          kglad Adobe Community Professional & MVP

          you can control your depths precisely, if needed, and don't use any negative depths.

           

          for movieclips you've added to the stage in the ide, initialize them by swapping depths so they all have depth greater than -1.  use num to assign their depths.

           

          with your duplicateMovieClip, use the method, not the function and use num to assign their depths.

           

          in addition, this line is problematic,

           

          duplicateMovieClip(DDD2, "DDD2" + num, _root.swapDepths(-15173));