-
AS2 tweening
I have a small flash file with slide out side panels. I need to be able to click on the left one and have it slide out, but also make sure the right one is slid back in place. I think the code I'm currently using is pretty close if anyone can help me tweak it.
Thanks
Code:
import mx.transitions.*;
import mx.transitions.easing.*;
this.attachMovie("leftBrain","leftBrain",1);
leftBrain._x = -209.8;
leftBrain._y = 149.8;
leftBrain._alpha = 100;
this.attachMovie("rightBrain","rightBrain",2);
rightBrain._x = 914.7;
rightBrain._y = 141.6;
rightBrain ._alpha = 100;
this.leftBrain.leftBtn.onRelease = function():Void {
slideFromLeft(leftBrain,71.2,149.8,2);
};
this.rightBrain.rightBtn.onRelease = function():Void {
slideFromRight(rightBrain,633.5,141.6,2);
};
// function to move movies
slideFromLeft = function (theMC:MovieClip, xVal:Number, yVal:Number, tweenSpeed):Void {
// get original values
startX = theMC._x;
startY = theMC._y;
// tween to center
moveXtween = new Tween(theMC, "_x", Strong.easeOut, theMC._x, xVal, tweenSpeed, true);
moveYtween = new Tween(theMC, "_y", Strong.easeOut, theMC._y, yVal, tweenSpeed, true);
// move old mc home
moveXtween = new Tween(_global.theOldMC, "_x", Strong.easeOut, _global.theOldMC._x, _global.theOldMC.xVal, tweenSpeed, true);
moveYtween = new Tween(_global.theOldMC, "_y", Strong.easeOut, _global.theOldMC._y, _global.theOldMC.yVal, tweenSpeed, true);
_global.theOldMC = theMC;
_global.theOldMC.xVal = startX;
_global.theOldMC.yVal = startY;
};
stop();
slideFromRight = function (theMC2:MovieClip, xVal:Number, yVal:Number, tweenSpeed):Void {
// get original values
startX = theMC2._x;
startY = theMC2._y;
// tween to center
moveXtween = new Tween(theMC2, "_x", Strong.easeOut, theMC2._x, xVal, tweenSpeed, true);
moveYtween = new Tween(theMC2, "_y", Strong.easeOut, theMC2._y, yVal, tweenSpeed, true);
// move old mc home
moveXtween = new Tween(_global.theOldMC2, "_x", Strong.easeOut, _global.theOldMC2._x, _global.theOldMC2.xVal, tweenSpeed, true);
moveYtween = new Tween(_global.theOldMC2, "_y", Strong.easeOut, _global.theOldMC2._y, _global.theOldMC2.yVal, tweenSpeed, true);
_global.theOldMC2 = theMC2;
_global.theOldMC2.xVal = startX;
_global.theOldMC2.yVal = startY;
};
stop();