You have a tween animation that has a duration, and a statement to set tweened property, so you've got a situation when two parts of your code change one variable while not knowing about it being changed elsewhere. The solution is to stop the tween before setting alpha.
}else{
if (tweenA.isPlaying) tweenA.stop(); // there!
buttons[i].associated.alpha = 0; // otherwise make the information corresponding to the button disappear
}
But you need to avoid a situation when one variable is related to multiple objects that can change concurrently, say you want both your "suspend" and "dissolve" associated texts to fade in at once (in different places maybe) and you have only one variable for a tween, you can't control them both. Here we meet the same thing: with this code as is you'll not be able to fade in any text but the last button's! This is because we use tweenA
for all possible tweens, even if there can be only one active at a certain time. So, we have to fix it a little more.
var tweenB:Tween; // a temporary tween for a new fade in animation
for (var i: int = 0; i < buttons.length ; i++){
if (buttons[i].associated == mc){ // if 'suspend' or 'dissolve' is clicked
tweenB = new Tween (buttons[i].associated, "alpha", Strong.easeOut, buttons[i].associated.alpha, 1, tweenSpeed, false);
// the line above makes the information corresponding to the button fade in
// and now we store a new tween in another var so that it won't be stopped at once
}else{
if (tweenA && tweenA.isPlaying) tweenA.stop(); // And here we stop old tween
// also protecting self from 1009 if no tween was stored yet
buttons[i].associated.alpha = 0; // otherwise make the information corresponding to the button disappear
}
}
tweenA=tweenB; // store newly created tween, if any (!) into our current tween var