Enlarge movieclip with easing

i would like to have a movieclip set to a certain size that is kept in a variable then on mouse over i would like the movieclip’s _xscale and _yscale to increase by 20 with easing and maybe a lil bounce. i can’t really figure it out though all i can get is


function(MCenlarge){
myMovieClip._xscale+=20;
myMovieClip._yscale+=20;
}

your help is greatly appreciated

Use the easing tutorial but change _x and _y to _xscale and _yscale :wink:

it doesn’t work :frowning:


function(MCenlarge){
	speed = 8;
	endX = this._xscale+20;
	endY = this._yscale+20;
	_xscale += (endX-_xscale)/speed;
	_yscale += (endY-_yscale)/speed;
}

then i call it with this on the button


on(rollOver){
this.MCenlarge();
}

Your function is written wrong for one.

  1. It is function nameOfFunction(){ }

  2. You can’t use “this” within a function.

  3. I don’t think you need _xscale and _yscale in the endX and endY

So your function should look like this…

function MCenlarge() {
	speed = 8;
	endX = 20;
	endY = 20;
	_xscale += (endX-_xscale)/speed;
	_yscale += (endY-_yscale)/speed;
}

And to call it, you use _root, not “this”…

on (rollOver) {
	_root.MCenlarge();
}

I didn’t test it, but those could be some things that are wrong.

And looking at it again… you define to enterframe so it will just contantly jump to a point.

it doesn’t do it still … it just get’s smaller and smaller … no easing … just jumps to the scale value

As my previous post stated, you define to onEnterFrame for it to keep working with.

Try using a prototype instead (since you can use “this” with a prototype). Something like this…

MovieClip.prototype.MCenlarge = function(endWidth, endHeight) {
	this.speed = 8;
	this.endX = endWidth;
	this.endY = endHeight;
	this.onEnterFrame = function() {
		this._xscale += (this.endX-this._xscale)/this.speed;
		this._yscale += (this.endY-this._yscale)/this.speed;
	};
};

Then on your button (which also has to be a movie clip I believe), do this…

on (rollOver) {
	this.MCenlarge(30, 30);
}
on (rollOut) {
	this.MCenlarge(100, 100);
}

The first number there is the _xscale value and the second number there is the the _yscale value.

savin me as always. thanks beta

No problem :slight_smile: It is my pleasure!