I've seen this done before, but I don't know the correct terminology...how do you change the "layer" a Flash sprite is in depending on where it is, whether it is (or looks like) it is in front or behind a sprite.
In other words, how can one accomplish "depth" with Flash sprites?
Take a look at my current problem:
Note how the one polar bear is on top of every other polar bear when walking upwards.
I've came across this: http://www.kirupa.com/forum/showthread.php?351346-Swap-depth-of-Movieclip-based-on-Y-location, but the code was of no help to me (I tried using it, but nothing changed).
This is an example of what I want to accomplish (note how the snail moves behind and in front of the sprites depending on its position):
This is a form of z-sorting. Basically all you need to do in AS3 is store your
Sprites
in an array and sort it based on they
position of each sprite. Then you loop through the array and add the sprites to the stage or anotherDisplayObject
continuously. You might think adding them like this is bad, but it's the normal way to do it.I made a demo for you on wonderfl : http://wonderfl.net/c/f54p
And here is the source code with a few comments: