3 Replies Latest reply on May 8, 2006 7:18 PM by Newsgroup_User

    depth of movieclips get ******-up

    Sarford
      Hi all,

      I have 15 instances of the same movieclip on my stage, all in the same level in the timeline.
      Through a script I give them all a unique levelnumber (setdepths).
      I put the levelnumbers of the movieclips in an Array (Lijst)
      I trace the levelnumbers to see if everything is ok, and it is.

      This is the code of frame 1:

      //var k = 1;
      var Lijst:Array = new Array ("");
      for (i=1; i<=15; i++) {
      _root["drop"+i+"_mc"].gotoAndStop(12);
      }
      for (i=1; i<=15; i++) {
      _root["drop"+i+"_mc"].swapDepths(i+10);
      var tijdelijk = (_root.Lijst.push(_root["drop"+i+"_mc"].getDepth()))
      }
      for (i=1; i<=15; i++) {
      trace(_root.Lijst );
      trace("drop"+i+"_mc : "+_root["drop"+i+"_mc"].getDepth());
      }

      On the second frame of the root movie again I check the array.
      I set the levelnumbers of the movieclips according the array.
      I trace again the levelnumbers of the movieclips.
      Again I put the levelnumbers in the array (in a later version of the code something will happen inbetween this).
      And again I trace the levelnumbers of the movieclips.

      Here is the code of frame 2:

      trace("///////////////////////////////////////////////////////");
      for (i=1; i<=15; i++) {
      trace("Nogmaals: "+_root.Lijst
      );
      }

      for (i=1; i<=15; i++) {
      _root["drop"+i+"_mc"].swapDepths(_root.Lijst.shift);
      }

      for (i=1; i<=15; i++) {
      trace("drop"+i+"_mc : "+_root["drop"+i+"_mc"].getDepth());
      }

      for (i=1; i<=15; i++) {
      var tijdelijk = (Lijst.push(_root["drop"+i+"_mc"].getDepth()))
      trace("watte???: "+_root.Lijst );
      trace("drop"+i+"_mc : "+_root["drop"+i+"_mc"].getDepth());
      }

      after that the root movie runs for another 30 frames or so (without any actionscripting) before being called at frame 2 again.

      here is the code from frame 30:

      gotoAndPlay(2);

      The strange thing is that this setup runs fine twice, after that it *****-up the levelnumbers of the movieclips. I have no idear whats going wrong (must be too late ).

      here are the traces from the output channel after the second run. It stays the same afterwards:

      ///////////////////////////////////////////////////////
      Nogmaals: 11
      Nogmaals: 12
      Nogmaals: 13
      Nogmaals: 14
      Nogmaals: 15
      Nogmaals: 16
      Nogmaals: 17
      Nogmaals: 18
      Nogmaals: 19
      Nogmaals: 20
      Nogmaals: 21
      Nogmaals: 22
      Nogmaals: 23
      Nogmaals: 24
      Nogmaals: 25
      drop1_mc : -16383
      drop2_mc : -16376
      drop3_mc : -16369
      drop4_mc : -16362
      drop5_mc : -16355
      drop6_mc : -16348
      drop7_mc : -16341
      drop8_mc : -16334
      drop9_mc : -16327
      drop10_mc : -16320
      drop11_mc : -16313
      drop12_mc : -16306
      drop13_mc : -16299
      drop14_mc : -16292
      drop15_mc : -16285
      watte???: 11
      drop1_mc : -16383
      watte???: 12
      drop2_mc : -16376
      watte???: 13
      drop3_mc : -16369
      watte???: 14
      drop4_mc : -16362
      watte???: 15
      drop5_mc : -16355
      watte???: 16
      drop6_mc : -16348
      watte???: 17
      drop7_mc : -16341
      watte???: 18
      drop8_mc : -16334
      watte???: 19
      drop9_mc : -16327
      watte???: 20
      drop10_mc : -16320
      watte???: 21
      drop11_mc : -16313
      watte???: 22
      drop12_mc : -16306
      watte???: 23
      drop13_mc : -16299
      watte???: 24
      drop14_mc : -16292
      watte???: 25
      drop15_mc : -16285

      Anyone have any cleu? Cause I'm without one, totaly...

      regards, Simon
        • 1. Re: depth of movieclips get ******-up
          Level 7
          Sarford wrote:
          > Hi all,
          >
          > I have 15 instances of the same movieclip on my stage, all in the same level
          > in the timeline.
          > Through a script I give them all a unique levelnumber (setdepths).
          > I put the levelnumbers of the movieclips in an Array (Lijst)
          > I trace the levelnumbers to see if everything is ok, and it is.
          >
          > This is the code of frame 1:
          >
          > //var k = 1;
          > var Lijst:Array = new Array ("");
          > for (i=1; i<=15; i++) {
          > _root.gotoAndStop(12);
          > }
          > for (i=1; i<=15; i++) {
          > _root.swapDepths(i+10);
          > var tijdelijk = (_root.Lijst.push(_root.getDepth()))
          > }
          > for (i=1; i<=15; i++) {
          > trace(_root.Lijst);
          > trace("drop"+i+"_mc : "+_root.getDepth());
          > }

          Using _root.getDepth() or _root.swapDepths() is most likely not what you
          want to do.

          _root is the base container for your movieclips. That means your
          movieclips have a depth *within* _root and the depth of _root is
          irrelevant. So you want to use the method "getNextHighestDepth()" on
          _root to know at what depth you can place your next movieclip in it;
          then you can use "swapDepths()" for the movieclips themselves, not for
          _root.

          hth,
          Tim.



          > On the second frame of the root movie again I check the array.
          > I set the levelnumbers of the movieclips according the array.
          > I trace again the levelnumbers of the movieclips.
          > Again I put the levelnumbers in the array (in a later version of the code
          > something will happen inbetween this).
          > And again I trace the levelnumbers of the movieclips.
          >
          > Here is the code of frame 2:
          >
          > trace("///////////////////////////////////////////////////////");
          > for (i=1; i<=15; i++) {
          > trace("Nogmaals: "+_root.Lijst);
          > }
          >
          > for (i=1; i<=15; i++) {
          > _root.swapDepths(_root.Lijst.shift);
          > }
          >
          > for (i=1; i<=15; i++) {
          > trace("drop"+i+"_mc : "+_root.getDepth());
          > }
          >
          > for (i=1; i<=15; i++) {
          > var tijdelijk = (Lijst.push(_root.getDepth()))
          > trace("watte???: "+_root.Lijst);
          > trace("drop"+i+"_mc : "+_root.getDepth());
          > }
          >
          > after that the root movie runs for another 30 frames or so (without any
          > actionscripting) before being called at frame 2 again.
          >
          > here is the code from frame 30:
          >
          > gotoAndPlay(2);
          >
          > The strange thing is that this setup runs fine twice, after that it *****-up
          > the levelnumbers of the movieclips. I have no idear whats going wrong (must be
          > too late ).
          >
          > here are the traces from the output channel after the second run. It stays the
          > same afterwards:
          >
          > ///////////////////////////////////////////////////////
          > Nogmaals: 11
          > Nogmaals: 12
          > Nogmaals: 13
          > Nogmaals: 14
          > Nogmaals: 15
          > Nogmaals: 16
          > Nogmaals: 17
          > Nogmaals: 18
          > Nogmaals: 19
          > Nogmaals: 20
          > Nogmaals: 21
          > Nogmaals: 22
          > Nogmaals: 23
          > Nogmaals: 24
          > Nogmaals: 25
          > drop1_mc : -16383
          > drop2_mc : -16376
          > drop3_mc : -16369
          > drop4_mc : -16362
          > drop5_mc : -16355
          > drop6_mc : -16348
          > drop7_mc : -16341
          > drop8_mc : -16334
          > drop9_mc : -16327
          > drop10_mc : -16320
          > drop11_mc : -16313
          > drop12_mc : -16306
          > drop13_mc : -16299
          > drop14_mc : -16292
          > drop15_mc : -16285
          > watte???: 11
          > drop1_mc : -16383
          > watte???: 12
          > drop2_mc : -16376
          > watte???: 13
          > drop3_mc : -16369
          > watte???: 14
          > drop4_mc : -16362
          > watte???: 15
          > drop5_mc : -16355
          > watte???: 16
          > drop6_mc : -16348
          > watte???: 17
          > drop7_mc : -16341
          > watte???: 18
          > drop8_mc : -16334
          > watte???: 19
          > drop9_mc : -16327
          > watte???: 20
          > drop10_mc : -16320
          > watte???: 21
          > drop11_mc : -16313
          > watte???: 22
          > drop12_mc : -16306
          > watte???: 23
          > drop13_mc : -16299
          > watte???: 24
          > drop14_mc : -16292
          > watte???: 25
          > drop15_mc : -16285
          >
          > Anyone have any cleu? Cause I'm without one, totaly...
          >
          > regards, Simon
          >
          • 2. depth of movieclips get ******-up
            Sarford Level 1
            Hi Tim, thank you for your reply.

            I'm afraid I don't quite follow you. It seems that in the quote you made some of the code dissapreared.
            Do you mean that instread of directly assigning a depth by:

            _root["drop"+i+"_mc"].swapDepths(i+10);

            I should use:

            _root["drop"+i+"_mc"].getNextHighestDepth(); ?

            regards. Simon

            ps: My old code works in that I can set depths of the movieclips, read them out, change them etc. Only... when I jump BACK on the timeline all levelnumbers are screwed, just like the list above. Even if I jump back from frame 1 its screwed...
            Strange thing is that at that moment I can't assign levelnumbers anymore.... but if I read them out they are still the same 'normal' levelnumbers....
            • 3. Re: depth of movieclips get ******-up
              Level 7
              Sarford wrote:
              > Hi Tim, thank you for your reply.
              >
              > I'm afraid I don't quite follow you. It seems that in the quote you made some
              > of the code dissapreared.
              > Do you mean that instread of directly assigning a depth by:
              >
              > _root.swapDepths(i+10);
              >
              > I should use:
              >
              > _root.getNextHighestDepth(); ?

              No I meant that "_root.swapDepths(i+10)" is just wrong. You say you have
              10 movieclips in _root and you want to assign them to some depth, right?
              So you need to think at what you want to do.

              What is the depth of a movieclip? The depth is the stacking order in
              which movieclips are drawn within their _parent movieclip. So since
              _root is the base clip, it has no _parent and the depth of _root has not
              meaning.

              If you want to adjust the depth of movieclips within _root then you must
              call "swapDepths()" on the movieclips directly. Like
              _root.mc1.swapDepths(1);
              _root.mc2.swapDepths(2);
              _root.mc3.swapDepths(3);

              If you want to avoid depth clashes, there is one function that can tell
              you what is the next available depth within a container clip. That is
              "getNextHighestDepth()" So you could use code like so:
              _root.mc1.swapDepths(_root.getNextHighestDepth());
              _root.mc2.swapDepths(_root.getNextHighestDepth());
              _root.mc3.swapDepths(_root.getNextHighestDepth());

              hth,
              Tim.

              PS: Try to avoid _root, it's a can of worms for later.