AS2 symbol depth conflict

209 Views Asked by At

I am using the following snippet to create a textured background.

tileBG = function () {

tile_width = 7.75;
tile_height = 7.75;

x_max = Math.round(Stage.width/tile_width);
y_max = Math.round(Stage.height/tile_height);
trace(x_max);
trace(y_max);
for (x=0; x<=x_max; x++) {

for (y=0; y<=y_max; y++) {

bg = _root.attachMovie("square", "bg"+x+y, this.getNextHighestDepth());
bg._x = tile_width*x;
bg._y = tile_height*y;
}

}


};

tileBG(); 

The problem I am running in to is the pattern/teture is showing up on top of everything (I am guessing it's because of this: getNextHighestDepth()). When I set a lower depth, say, 2 it fails because of the repeating effect, if I do 2+x it fails because there are about 8 layers above this layer which probably have some of the same depths being assigned.

I am wondering if anyone has a solution for this, or if I can force my top layers (8 or so) to have a specific depth, say, 100+ or something like that.

1

There are 1 best solutions below

0
Emilien Schneider On

Create an empty clip in your stage that is at the depth where you want to attach your pictures and place it in position 0x0. Let's say it would be called "mcTexture".

Then, you can modify your code line in which you call "attachMovie" :

bg = mcTexture.attachMovie("square", "bg"+x+y, mcTexture.getNextHighestDepth());