PDA

View Full Version : Adding Ease



mdipi
April 21st, 2003, 05:05 PM
ok i made this file [link (http://www.mdipi.com/sorry/grow.html)] 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:

mdipi
April 21st, 2003, 05:10 PM
the link is loadng hella slow so here is the attached fla:

:-\

ahmed
April 21st, 2003, 05:14 PM
gimme 5 minutes i'll do it for ya :)

ahmed
April 21st, 2003, 05:24 PM
there you go :)

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;
};
}

mdipi
April 21st, 2003, 05:25 PM
sweet! thanks. i just chame my grow funtion out

mdipi
April 21st, 2003, 05:27 PM
(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...

ahmed
April 21st, 2003, 05:42 PM
_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 :)

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

mdipi
April 21st, 2003, 05:49 PM
yep i get it now, i was really confused w/the last part cause i dont know that much yet