whenever you think of oscillating motion/behavior think sine or cosine functions… remember back in high school trig, sine and cosine functions when graphed look like smooth wave curves undulating between 1 and -1.
you can use that undulating function for just about anything that you want to continuously oscillate between two values. so and expression like this could be used in the glow radius:
f = 1; // variable for frequency of pulse in seconds
a = 10; // variable for amount of glow
(Math.cos(time * f * 2 * Math.PI) + 1) * (a / 2);
the last line looks a bit complicated, but it’s not really… we used the Math cosine function from java (Math.cos). within that you need it to oscillate over time (time). Math.cos(time) will by itself create oscillation, but we mulitply the frequency (f) to allow the frequency to be adjusted to suit our needs. the *2*Math.PI allows the frequency to be set in seconds, it’s not necessary, but it’s nice to have a tangible measure for time. since cosine oscillates between 1 and -1 and we can’t have a negative glow, i added 1 (+1) to the cosine value to smoothly go from 2 to 0 (we could have tried an absolute function (Math.abs()) to return only positive values, but the value would not ease to zero, but kind of bounce back up from zero). then we need to multiply everyting by our amount. since our value for cosine is now 2 times as large, to keep our amount proportionate we just halved the amount (a) variable.
if you want to learn more about expressoin, i suggest dan ebbert’s motionscript.com and jj gifford’s site on expressions
Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW