3 Replies Latest reply on Aug 6, 2008 10:11 AM by Shandy Elliott

    drag + drop to swap depth

    luciewong Level 1
      Hi,
      I have a list of 10 emptyMovieClips, each representing a "Depth".
      So the top EMC is depth 0, the last in the list represents depth 9.

      I want to drag and drop now for ex. the EMC number 10 to the top, so he inherits the depth 0 of the top EMC, while the top EMC with depth 0 should inherit the depth 9 of the moved and dropped EMC. cool.

      How could I achieve this and where could I start??

      Thanks
        • 1. Re: drag + drop to swap depth
          Shandy Elliott Level 1
          Use swapDepths() with your onPress (or whatever event you are using). Example:

          mc1.onPress=function() {
          this.swapDepths(_root.getNextHighestDepth);
          this.startDrag();
          }

          That will place the object at the top of the stacking order once you press it. Or you could have it swapDepths() with another movie clip instance name. This part really would determine how your stage is set up because I can't visually understand your purpose.
          • 2. Re: drag + drop to swap depth
            luciewong Level 1
            Hi, thank you for your reply,
            The purpose is:
            I have 7 components attached to my root. Each component has its depth (from 0 to 6);
            The data comes in from an array like>
            theDepth_array = [0,1,2,3,4,5,6];

            Also the components names come in from an array like>
            sub1_array = [compA,compB,compC,compD,compE,compF,compG];
            sub1L = sub1_array.length;

            Now with the >sub1_array< I create a list with code below>(code is reduced, but you can see what I want)


            function createDisplay(){

            this.createEmptyMovieClip("holderSub_mc",mydepth+2998);//


            //create the TFs>THE LIST>
            for(a:Number = 0;a<sub1L;a++){ this.holderSub_mc.createEmptyMovieClip(["sub1_mc"+a], (sub1depth)+a);//
            this.holderSub_mc["sub1_mc"+a].avar = a;//<<
            this.holderSub_mc["sub1_mc"+a].createTextField(["sub1_txt"], (sub1depth_txt)+a,sub1X, sub1Y, sub1W, sub1H);
            this.holderSub_mc["sub1_mc"+a]["sub1_txt"].type = "dynamic";
            this.holderSub_mc["sub1_mc"+a]["sub1_txt"].text = sub1_array[a];//
            this.holderSub_mc["sub1_mc"+a]["sub1_txt"].setTextFormat(sformatM);
            }
            };

            //xxx

            I have now a list of items + beside a list of depths.
            So compA would be on top representing the depth 0
            The comG is last in the list representing depth 6

            All I want is to be able to change the depth of a component by pressing it and moving to a desired other position.
            I want to be able to change the depth of compG [6] by moving it up to compA, so compG has the depth 0 and compA has then the depth 6.

            If this could be done with RollOver and Press/Relaese actions without drop/drag then I am happy.
            For example, I >press< compG – hold it down and move to the top over compA and >Release</

            - if I could achieve a data exchange ( depth + text ) would be perfect.
            Then no need for physical drop+drag.
            Maybe with a MouseMove action?
            The arrays update with splice/onRelease would then be no problem.

            Hope I made myself clear.
            Thankyou
            • 3. Re: drag + drop to swap depth
              Shandy Elliott Level 1
              As detailed as your description is, it makes even less sense what you are trying to achieve. Can you send me the fla file?