Alright, how 'bout this?

This is what I’ve come up with for my previous problem in my other post. Bare with me… I’m fairly new to AS and I don’t know how great my coding skills are. Anyhow, it’s doing EVERYTHING I want it to do, EXCEPT easing into the new position when a button is clicked. Download the files and you’ll see what I mean. I want the blue squares to ease into their “zoomed” position and then ease back to their original position when the button is clicked again. I thought that setting up a loop within the function would do it, but I guess I didn’t take into account how fast PCs actually perform! =) Any help with this is greatly appreciated.

Oh yeah, you need to click the same button to get the blue square back to its original position. If you click the other one, it won’t work. I’m going to disable all buttons when one is clicked to eliminate this problem once I get this easing thing squared away.

 
//declare variables
endX = 640;
endY = 512;
endW = 468;
endH = 401;
endR = 0;
i = 0;
k = 0;
speed = 5;
var currentX;
var currentY;
var currentH;
var currentW;
var currentR;
var currentClip;
var returnX;
var returnY;
var returnH;
var returnW;
var returnR;

  

//load external movies
//set different property values for each movie clip
function loadContent() {
 //pic1_mc.loadMovie("pic1.swf");
 pic1_mc.loadMovie("blue.swf");
 pic1_mc._xscale = 25;
 pic1_mc._yscale = 25;
 pic1_mc._rotation = -28;
 pic1_mc._x = 300;
 pic1_mc._y = 300;
 //pic4_mc.loadMovie("pic4.swf");
 pic4_mc.loadMovie("blue.swf");
 pic4_mc._xscale = 25;
 pic4_mc._yscale = 25;
 pic4_mc._rotation = 67;
 pic4_mc._x = 600;
 pic4_mc._y = 600;
}
loadContent();

 

//define zoom function
_global.zoom = function() {
 if (i == 0) {
  j = 0;
  while (j<50) {
   currentClip._x += (endX-currentClip._x)/speed;
   currentClip._y += (endY-currentClip._y)/speed;
   currentClip._height += (endH-currentClip._height)/speed;
   currentClip._width += (endW-currentClip._width)/speed;
   currentClip._rotation += (endR-currentClip._rotation)/speed;
   j++;
  }
  i++;
 } else {
  j = 0;
  while (j<50) {
   currentClip._x += (returnX-currentClip._x)/speed;
   currentClip._y += (returnY-currentClip._y)/speed;
   currentClip._height += (returnH-currentClip._height)/speed;
   currentClip._width += (returnW-currentClip._width)/speed;
   currentClip._rotation += (returnR-currentClip._rotation)/speed;
   j++;
  }
  i--;
 }
};

 

//define currentCoords function
_global.currentCoords = function() {
 currentX = getProperty(currentClip, _x);
 currentY = getProperty(currentClip, _y);
 currentH = getProperty(currentClip, _height);
 currentW = getProperty(currentClip, _width);
 currentR = getProperty(currentClip, _rotation);
};

 

//define returnCoords function
_global.returnCoords = function() {
 returnX = getProperty(currentClip, _x);
 returnY = getProperty(currentClip, _y);
 returnH = getProperty(currentClip, _height);
 returnW = getProperty(currentClip, _width);
 returnR = getProperty(currentClip, _rotation);
};

 

//button functionality
//one button for each movie clip
button1_mc.onRelease = function() {
 if (k == 0) {
  currentClip = pic1_mc;
  currentCoords(currentClip);
  returnCoords(currentClip);
  zoom();
  k++;
 } else {
  currentClip = pic1_mc;
  zoom();
  k--;
 }
};


button4_mc.onRelease = function() {
 if (k == 0) {
  currentClip = pic4_mc;
  currentCoords(currentClip);
  returnCoords(currentClip);
  zoom();
  k++;
 } else {
  currentClip = pic4_mc;
  zoom();
  k--;
 }
};