views:

26

answers:

2

I have a 3D field with many MovieClips in it, and seems like the one last added is the one that overlaps others and not the one with highest z value.
Is there any property/function that sets z-index? (sorting children by z value seems too much like a hack).
A 3D engine that can place MovieClips will be helpful(but not one that requires custom drawing).
I'm using Flash CS5 with ActionScript 3

+1  A: 

You're looking for parent.setChildIndex. You can use that or swapChildren to move the z-index of children around.

umop
I can't set 2 children index to the same value althou that can happen.
Dani
If you specify an index which already exists, it will just insert that object and shift everything between the old location and the new. From the documentation: When you use the setChildIndex() method and specify an index position that is already occupied, the only positions that change are those in between the display object's former and new position. In the case of swapChildren, it will just swap the two and thus, nothing will be shifted.
umop
A: 

flash itself has no z-index sorting with the 3D space, so you have to either pull a completely new 3D engine or sort it manually every frame.

no matter what happens you will always get some problem when trying to overlap two planes on the same z co-ordinate, even in full 3D engines, you have to decide which one you want to be in front of the others or you will get flickering as each frame they change places.

personally i work with Away3D as an engine, and that has the possibilities for 'MovieMaterial' to a plane (which is probably what you are meaning) but it think this is a pretty general use and can be used in Papervision etc. too.

shortstick