Z Order Swapping

Hello.
I am creating a simple navigation menu. It consists of two arrows, forward and backward.
When only the forward arrow is applicable, then it will sit in the “center” (and vice versa), when both are applicable, they will be stacked on top of eachother about the “center.”

Here is the code from my “NEXT” label (these labels are navigated to flawlessly by the parent class)


this.stop();

import fl.transitions.Tween;
import fl.transitions.easing.*;

//change the alphas
var nextNavAlphaN:Tween = new Tween
(nextNavMC, "alpha", Strong.easeOut, nextNavMC.alpha, 100, 1, true);
var prevNavAlphaN:Tween = new Tween
(prevNavMC, "alpha", Strong.easeOut, prevNavMC.alpha, 0, 1, true);

//change the position, 
//both will be located at 0 when only one is visible
var nextNavPosN:Tween = new Tween
(nextNavMC, "y", Strong.easeOut, nextNavMC.y, 0, 1, true);
var prevNavPosN:Tween = new Tween
(prevNavMC, "y", Strong.easeOut, prevNavMC.y, 0, 1, true);

//nextNavMC.z = 1;
//prevNavMC.z = 0;

this.setChildIndex(nextNavMC,1);
this.setChildIndex(prevNavMC,0);

And the “PREV” label


this.stop();

import fl.transitions.Tween;
import fl.transitions.easing.*;

//nextNavMC.alpha = 0;
//prevNavMC.alpha = 100;

//change the alphas
var nextNavAlphaP:Tween = new Tween
(nextNavMC, "alpha", Strong.easeOut, nextNavMC.alpha, 0, 1, true);
var prevNavAlphaP:Tween = new Tween
(prevNavMC, "alpha", Strong.easeOut, prevNavMC.alpha, 100, 1, true);

//change the position, 
//both will be located at 0 when only one is visible
var nextNavPosP:Tween = new Tween
(nextNavMC, "y", Strong.easeOut, nextNavMC.y, 0, 1, true);
var prevNavPosP:Tween = new Tween
(prevNavMC, "y", Strong.easeOut, prevNavMC.y, 0, 1, true);

//nextNavMC.z = 0;
//prevNavMC.z = 1;

this.setChildIndex(nextNavMC,0);
this.setChildIndex(prevNavMC,1);

the “NEXT AND PREV” is similar but naturally sets the alphas to 100 and the y position to 40 and -40 respectively.

I can’t describe exactly what’s going wrong except that the result is not at all what I want. Sometimes one of the buttons is on top of the other when it shouldn’t be, disabling the one that should be activate, sometimes neither of the two fade out from their stacked position. As you can see, I have tried simply changing the z value of each movieclip.

Any thoughts?

Thanks.