3 Replies Latest reply on Aug 17, 2007 11:22 AM by IlikeIke

    AS3 depth management issue

    IlikeIke Level 1
      Hello folks! Looking for a little technical advice - let me explain:
      I'm converting a small flash game that I had built in flash 8 with as2 to flash 9 with as3 and have hit a snag. The visible object on the stage in that application is simialr to a rubiks cube as seen from an upper corner (sort of an isometric view). There are mutliple rows and columns and levels...lets just say it's a 3x3x3 cube. Through gameplay various cubes are moved around, added and removed from the grid, sometimes a slot is empty sometimes full. In order to track this and make sure that the cubes stay at the proper depth relative to each other I had assigned each slot in the full grid a grid number incremented by 10's for rowsand 100's for layers and stored the numbers in an array. Then when I added a cube to the stage I just looked up its depth value from the array, attached it and appended its number to it's instance name and set it's depth to the same number . Nothing ever got at an improper depth becuase every slot had a fixed absolute number that could be pulled from the array. My problem is that the new depth manager won't allow gaps - each depth needs to be used before the next one can be used, and that when you insert someting at an occupied depth everything above it is pushed up by one so I can't track any of my cubes depth as I had been becuase they keep changing.

      Example: I'm my old system if I needed to move the first row of cubes from the 3rd layer (cubes 310, 320, 330) straight down into the second layer I would simply move them then swapdepth to 210, 220, 230. In the new system since i cant reserve a depth for an empty slot I never know what number to move the cube to without a convoluted lookup process, and once I do move it...every single depth after it gets altered (which seems like a lot of extra work for the system by the way)

      So...anyone know a better way to manage depths of a 3 dimensional grid in as3?
        • 1. Re: AS3 depth management issue
          Greg Dove Level 4
          Hmm. Sounds like fun.

          I haven't played enough with as3 yet. But can't you do re-parenting of clips in as3?
          If that's true, couldn't you set up some 'parents' for the 'depth layers' in a fixed z-order sequence and move child clips between them? I'm not sure if its possible, but I'd be keen to know if its a workable solution too.

          • 2. AS3 depth management issue
            abeall Level 3
            Personally, I think the new depth system introduces more problems than it fixes.

            One advantage in AS3, though, is that you can move a DisplayObject from one DisplayObjectContainer to another.
            [edit] Oops, GWD already mentioned this, so I'm basically re-iterating what he said [/edit]

            So based on your setup, it might be helpful to make different container clips for each "layer" as you described it. Then you can simply move the rows into the different containers, and the containers are at different depths.
            • 3. Re: AS3 depth management issue
              IlikeIke Level 1
              Hmm sounds worth a try...If I set up a new empty container for each and every cube slot that should serve to hold the depth open for the cubes that I could move into and out of the appropriate containers later. Will let you guys know how it works out ;)