# \[as2\] how to know when mx.transitions have completed?

**URL:** <https://forum.kirupa.com/t/as2-how-to-know-when-mx-transitions-have-completed/70613>\
**Category:** flash\
**Created:** [November 15, 2004, 7:39pm UTC](https://forum.kirupa.com/t/as2-how-to-know-when-mx-transitions-have-completed/70613 "2004-11-15T19:39:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stimulus](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@stimulus](https://forum.kirupa.com/u/stimulus)\
**Post date:** [November 15, 2004, 7:39pm UTC](https://forum.kirupa.com/t/as2-how-to-know-when-mx-transitions-have-completed/70613/1 "2004-11-15T19:39:24Z")

</div>

I’ve stripped out a bunch of other actions in my AS code to highlight the problem I’ve having.

In this example, I have a movie that uses _mx.transitions_ to fade one movieclip out and another in when the user clicks a button.

_bOnState_ is a variable that keeps track of which movieclip is “on”. true for one, false for the other. (works here…) 🙂

Anyway, if the button is clicked rapidly the transitions start tripping over one another and I can end up with both images faded up or vice versa. Essentially, it starts another transition before the first finishes.

\*\*What’s the best way to know my transitions are complete since they’re not really frame-based? Make sense?  
\*\*

```auto
btButOne.onRelease = function ():Void {
if ((bOnState == false) || (bOnState == undefined)) {
	bOnState = true;
	fadeOut(mcRoad, .7);
	fadeIn(mcPicRight, .5);
} else if (bOnState == true) {
	bOnState = false;
	fadeOut(mcPicRight, .5);
	fadeIn(mcRoad, 1);
}
};

function fadeIn(mc, time):Void {
    easeType = mx.transitions.easing.Strong.easeOut;
    var begin = 0;
    var end = 100;
    varTrans = new mx.transitions.Tween(mc, "_alpha", easeType, begin, end, time, true);
}

function fadeOut(mc, time):Void {
    easeType = mx.transitions.easing.Strong.easeOut;
    var begin = 0;
    var end = 100;
    varTrans = new mx.transitions.Tween(mc, "_alpha", easeType, begin, end, time, true);
}

```
