Adding Ease

ok i made this file [link] and want to make the "growing a bit smoother. i dont know how to add easing or interia (i cant spell or put my hand on the name) so can some one help? plz?:beam:

the link is loadng hella slow so here is the attached fla:

:-\

gimme 5 minutes i’ll do it for ya :slight_smile:

there you go :slight_smile:

function grow() {
	originalSizeY = _yscale+15;
	originalSizeX = _xscale+15;
	onEnterFrame = function () {
		differenceY = originalSizeY-_yscale;
		differenceX = originalSizeX-_xscale;
		(Math.floor(differenceY) == 0) ? delete this.onEnterFrame : _yscale += differenceY/3;
		(Math.floor(differenceX) == 0) ? delete this.onEnterFrame : _xscale += differenceX/3;
	};
}

sweet! thanks. i just chame my grow funtion out

(Math.floor(differenceY) == 0) ? delete this.onEnterFrame : _yscale += differenceY/3;
                (Math.floor(differenceX) == 0) ? delete this.onEnterFrame : _xscale += differenceX/3;

ahmed can you break that part down for me? i dont quite get whats going on…

_yscale += differenceY/3;
_xscale += differenceX/3;

this part is responsible for the easing. Let’s say the _xscale is 100, and you want it to be 120, what you would do it:


1. calculate 120-_yscale> store that in the variable 'difference' ( gives '20' )
2. add difference/3 ( adds '20/3' )
3. goto 1 >> 1. calculate 120-_yscale> store that in the variable 'difference' ( gives '13' )
             2. add difference/3 ( adds 13/3 )

… and so on… thus, you get the easing effect.

the other part is simply to check whether it has reached the desired size, if it did, it deletes the onEnterFrame function :slight_smile:

i know it’s not that clear, but i hope you get the general idea :slight_smile:

yep i get it now, i was really confused w/the last part cause i dont know that much yet