5 Replies Latest reply on Dec 3, 2007 12:43 PM by influxxmedia

    dynamic MC _level

      Hi, I am trying to create a dynamically generated MC with creatEmptyMovieClip(), and all works well. But looking the list of objects/variables in the show I can't seem to detect at what _level the clip is generated. I am using getNextHighestDepth() to set the level (see code below).

      Ultimately what I am hoping to happen is that each successive MC will be generate OVER (or on the _level above) the existing MC. Currently it looks like the existing MC is replaced when the new MC is generated.

      My next question would be (once I get this lot working) how do I then remove the MC that is under the newly generated MC. I imagine the RAM or processor wont mind if a few _levels of MCs are stacked up and this wont be running up more than about 20 _levels max. But for the purpose of best practice.

      Thanks guys. Your help is always greatly appreciated.
        • 1. Re: dynamic MC _level
          kglad Adobe Community Professional & MVP
          you're discussing depths, not levels.

          you can find the depth of any movieclip using its getDepth() method.

          if two movieclips have the same parent, the one with greater depth will appear above the other. if two movieclips have different parents, the first generation (ie, closest to the main timeline) where they have different ancestors will determine their appearance: the movieclip whose ancestor has greater depth will appear above the other.

          you can remove any movieclip with depth greater than -1, by using the removeMovieClip() method. you can use swapDepths() to facilitate the removal of any movieclip, no matter its depth.
          • 2. Re: dynamic MC _level
            influxxmedia Level 1
            great info kglad

            Many thanks. Got lots to read up on now.

            • 3. Re: dynamic MC _level
              kglad Adobe Community Professional & MVP
              you're welcome.
              • 4. Re: dynamic MC _level
                influxxmedia Level 1
                Trying to understand the relationship between the various layers of the stacking order, and the depths within them.

                I have this code :

                This is purely as an exercise, not any working project. When I trace the depths of those MCs, the output window returns this:

                So the dynamically created MC is assigned to depth 1 and is traceable. But the MC that is attached is untraceable to any depth. Is there a way to figure out what its depth is, or is it a matter of creating another MC, nested inside the first created MC, and attaching the linked object to it. Whereby its depth can be traced, and hence swapped etc

                many thanks
                • 5. Re: dynamic MC _level
                  influxxmedia Level 1
                  More research into depth swapping and removal of MCs revealed an inability to repeatedly set the depth of a dynamically created MC. The code is called every 2 secs (for dev for now) via a setInterval(). One would expect the value of n to increase and it does, but that value does not get 'piped through' to the argument of the createEmptyMovieClip() method.

                  The code below returns this output:
                  first mc : 5
                  first mc : 5
                  first mc : 5

                  Any thoughts on why this happens, and ways around it, would be deeply appreciated. This is a huge stumbling block and my program was built on the assumption I could do something like this