swapDepths of tweening mc

Hi,

There’s a static movieclip on the stage, and another movieclip attached dynamically to the root. I swap their depths, so the static one is in front. No problems so far…

A couple of frames later, I ask the static one to start motion tweening. It refuses and just sits there. True, the Flash help docs state that if you swapDepths on a tweening movieclip, the tweening stops.

If a movie clip is tweening when this method is called, the tweening is stopped.

So apparently this holds true even when the swapping was done at an earlier different keyframe.

I’ve managed to do it like this: swap the depths of attached mc, without touching the depth of tweening mc. Like so:

var depthLevel = myStatic_mc.getDepth(); 
myDynamic_mc.swapDepths(depthLevel-1);      //place it behind the tweening myStatic_mc

But this is risky business…you don’t know if another movieclip resides on depthLevel-1.

What is a better work-around for this?

Thanks for your feedback.