[FMX] Sequence of functions

Hi,

I’m making a menu. It consist of three mc’s (btn1, btn2 and btn3) and two squares The two squares rescale horizontal in different directions depending on the button that is presses. When the squares come to an hold there is a little gap between them underneath the button that was presses and the button is going 20 pixels down into that gap. Below is the code I have used:

MovieClip.prototype.yPos = function(y){
 this.onEnterFrame = function(){
  this._y += (y - this._y)/3;
  if (this._y > y - 1 && this._y < y + 1){
   delete this.onEnterFrame;
  }
 }
}
function fadeClips (total, alpha){
 for (var i = 1 ; i <= 3; i++){
  this["btn"+i].onEnterFrame = function(){
   this._alpha += (alpha - this._alpha)/5;
	if (this._alpha > alpha - 5 && this._alpha < alpha + 5) {
	delete this.onEnterFrame;
	btn1.yPos(50);
	}
  }
 }
}
MovieClip.prototype.scale = function(w){
 this.onEnterFrame = function () {
  this._width += (w - this._width)/5;
  if (this._width > w - 1 && this._width < w + 1) {
   delete this.onEnterFrame;
   fadeClips (3, 99);
  }
 }
}
btn2.onRelease = function(){
 this.yPos (50);
 btn1.yPos (30);
 btn3.yPos (30);
  mc1.scale (110);
  mc2.scale (390);
 }
mc1.scale (50);
mc2.scale (450);

When the movie starts everything is fine. First the two squares are rescaling. When that is done the buttons are fading in and finaly btn1 is going 20 pixels down in to the gap. But what I would like to accomplish now is that when btn2 is pressed that first btn1 is going back up again when that is done that the two squares are rescaling untill the gap is below btn2 and that after that btn 2 is going down 20 pixels.

And that is where I have problems. Point one when I don’t know how to integrate a if (if used) in the button event, so everything is going to move at the same time(btn2 already moves before the squares are in place and the squares are already moving before btn1 is back up again) and secondly the way I have it now btn1 is indeed moving back up again, but after that its up it also going back down again. I think that has to do that the first call back for btn1 is inside one of the functions, but I don’t know how to solve it.

Here is also a link to the Fla

http://www.testfolder.com/testMenu.htm

I hope there’s somebody who can help me :slight_smile: