Swapdepth, z-positie, particles.. aaarrgh

Hey folks, I’ve got a problem.
I have this 3D engine with pivots that contain particles.
When I render the mc’s (particles) I need to assign the right depth:
some mc’s should be on top, some beneath others.

The problem is that everything is utterly bugged:

  • mc’s blink like crazy while battling for the same depth
  • mc’s don’t animate behind or above others, when they are supposed to
  • mc’s disappear for another mc has overwritten the others with the depth

So that pretty much sucks. Now what? … HELP!!!
Underneath I have 5 experiments to solve my problem. None work properly.
Normally the depth of a mc would be derriven from it’s z-position.
In my case it’s a bit more complex: I’d like to assign a depth to each pivot
so that it’s particles won’t interfere with the particles of other pivots.
This way I contain the particles nicely in their abstract “containers” (pivots).

var swapType = 0;
switch (swapType) {
default:
// e.g: Number("20" + "1") = 201
mc.swapDepths(Number(String(pivot.depth)+String(depth)));
break;
case 1:
// e.g: round(20 + 352.58844677 + 1) = 374
mc.swapDepths(Math.round(pivot.depth+((100000-position3D.z)/10 + depth)));
break;
case 2:
mc.swapDepths(Math.round((100000-position3D.z)/10 + depth));
break;
case 3:
mc.swapDepths(100000 - position3D.z*100 + depth);
break;
case 4:
var d = (1 / ((position3D.z/perspective) + 1));
mc.swapDepths(d * 500);
}

Who can help me solve this problem? I’m reaching out here…
So I’d like to use a manual assigned a depth to a pivot, to group it’s
particles above or below other pivot’s particles. The only reason I gave
a particle a depth is to temporarly solve a little problem when more particles
have the same z-position, so they won’t have to fight over the depth.

Thanks in advance! - Mediamonkey