# One movement after the other

**URL:** <https://forum.kirupa.com/t/one-movement-after-the-other/160666>\
**Category:** flash\
**Created:** [August 28, 2005, 8:30am UTC](https://forum.kirupa.com/t/one-movement-after-the-other/160666 "2005-08-28T08:30:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)\
**Post date:** [August 28, 2005, 8:30am UTC](https://forum.kirupa.com/t/one-movement-after-the-other/160666/1 "2005-08-28T08:30:47Z")

</div>

I have two squares on stage (square1, square2) ! I use a prototype for moving and transforming the squares:

```auto
MovieClip.prototype.easeTo = function(tarW, tarH, tarX, tarY) {
this.onEnterFrame = function() {
this._width = tarW-(tarW-this._width)/1.2;
this._height = tarH-(tarH-this._height)/1.2;
this._x = tarX-(tarX-this._x)/1.2;
this._y = tarY-(tarY-this._y)/1.2;
if (Math.abs(this._width-tarW)<1 && Math.abs(this._height-tarH)<1 && Math.abs(this._x-tarX)<1 && Math.abs(this._y-tarY)<1) {
this._width = tarW;
this._height = tarH;
this._x = tarX;
this._y = tarY;
delete this.onEnterFrame;
}
};
};

```

I made two arrays with the demension for both squares

```auto

var tarW, tarH, tarX, tarY;
mainSq = new Array();
mainSq = [{tarW:200, tarH:200, tarX:50, tarY:50}, {tarW:300, tarH:150, tarX:250, tarY:125}, {tarW:100, tarH:300, tarX:250, tarY:150}];
subSq = new Array();
subSq = [{tarW:100, tarH:100, tarX:50, tarY:50}, {tarW:150, tarH:75, tarX:200, tarY:100}, {tarW:50, tarH:150, tarX:250, tarY:250}];

```

My menus structure to control the squares is like this:

```auto

buttons = new Array();
buttons = ["home", "about", "service", "products", "enquiry", "contact"];
function setButton() {
for (var i in menuMc) {
if (menuMc*._name.substr(0, 4) == "btn_") {
clip = menuMc*;
for (j=0; j<buttons.length; j++) {
if (menuMc*._name.substr(4) == buttons[j]) {
clip.j = j;
}
 
}
clip.onRelease = function() {
var mSq = mainSq[this.j];
var sSq = subSq[this.j];
_root.square1.easeTo(mSq.tarW, mSq.tarH, mSq.tarX, mSq.tarY);
_root.square2.easeTo(sSq.tarW, sSq.tarH, sSq.tarX, sSq.tarY);
};
}
}
}
setButton();

```

When I press one of the buttons the two squares moving (and rezising) to another position both at the same time, but what i would like to accomplish is that square 2 only moves when square1 is in position. How can I accomplish that?
