I have two squares on stage (square1, square2) ! I use a prototype for moving and transforming the squares:
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
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:
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?