|
First declare, define
and assigned a values to varible.
var t:Number = 0;
var dt:Number = 0.2;
var amp:Number =200;
A function is created
the is called everytime the movie clip "ball_mc"
enteres a new frame.
ball_mc.onEnterFrame = function(){
Inside this a new function is
created to
calcualtes the acceleration which is exponentialy
related to the time passed. This is then multipled
by the acceleration factor "amp", the
Sine of time passed "t"
and the time interval "dt" to give the
change in position.This value is then returned.
ball_mc._x += amp*(1/t)*Math.sin(t*Math.PI/2+Math.PI/2)*dt
An interval amount is added
to the total running time.
t += dt;
Each time the mc enters a new
frame an amount is added to the position of the
mc. This amount is directly propertional to the
amplitude "amp" the sine of time "t" and
the time interval "dt"but inversely proprtional
to t. As the sine function is periodic the changing
t value causes the value of sine to periodically
change from positive to neagtive causing the acceleration
of the object to change from positive to negative
and give a sinusidual ease and simple harmoic motion.However
becaue this amplitude is scaled inversly to t as
t increases their amplitude of the ocillation and
the resulting ease is decreased giving the effect
of a damped oscillation or sinosidual easeout.
To learn more about simple harmonic motion see
[shm with actionscript]
|