Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

drag and drop duplicates and swap depth problem

Guest
Jul 03, 2014 Jul 03, 2014

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 ();

};

TOPICS
ActionScript
263
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2014 Jul 03, 2014
LATEST

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));
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines