PDA

View Full Version : Scaling in relationship to X position



sevenxsix
March 9th, 2005, 01:32 PM
Hey all,

I've tried to do this a few times, and there's got to be a better way.

Essentially I want a MC to take it's X position and magically set its x and yscale, so that when it is at an X of 0, it's xscale is 75, when it's at a X of 88, it's xscale is 100, and when it's at a X of 176, its scale is 75 again.

But it needs to scale from 75 to 100 and back to 75 smoothly, while it's being moved by another script.

Any ideas?? Greatly appreciated.

mpelland
March 9th, 2005, 02:02 PM
_root.onEnterFrame = function () {

var scaleDir = new Number;
var scaleBy = new Number;

scaleDir = Math.floor(scaler_mc._x / 88);

scaleBy = scaler_mc._x - (88 * scaleDir);

if ((scaleDir % 2) == 0) {
scaleBy = 100 - ((scaleBy / 100) * 25);
} else {
scaleBy = 75 + ((scaleBy / 100) * 25);
}

scaler_mc._xscale = scaleBy;

}

scaler_mc.onPress = function() {
this.startDrag();
}

scaler_mc.onRelease = function () {
this.stopDrag();
}

mpelland
March 9th, 2005, 02:03 PM
scaler_mc is the movie clip that is being scaled.

sevenxsix
March 9th, 2005, 03:30 PM
Thanks, that's put me in the right direction. :D

mpelland
March 9th, 2005, 03:37 PM
good to hear... if you need anything else just holler