Copy link to clipboard
Copied
I've animated a layer with multiple position keyframes, and now I want some of those keyframes - but not all of them - to have an overshoot expression applied. In other words, I want an expression to only affect certain specific keyframes on a layer.
I've been told that it's possible to do this using a checkbox control and keyframe the expression on or off as necessary. Unfortunately, I have no coding experience and I can't work out how to link an expression to a checkbox such that the checkbox can be used to enable or disable that expression.
Any advice gratefully received!
Copy link to clipboard
Copied
This is a keyframe overshoot expression from my site, which I've modified to skip the overshoot unless the checkbox is on at that keyframe. It may not exactly fit whatever you're using for overshoot, but hopefully it will give you an idea on how to incorporate the checkbox.
cb = effect("Checkbox Control")("Checkbox");
freq = 3;
decay = 5;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
if (n > 0 && cb.valueAtTime(key(n).time)){
t = time - key(n).time;
amp = velocityAtTime(key(n).time - .001);
w = freq*Math.PI*2;
value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
value
Copy link to clipboard
Copied
Many thanks Dan, that's much appreciated!
As I say, I have no coding experience (short of writing very basic BASIC back in the 80s), and I want to learn how the Javascript syntax works. I think I can work out that your script only runs the overshoot code if the value returned by the checkbox is greater than 0, but I want to understand it properly - can you recommend any resources for beginners?
Copy link to clipboard
Copied
I just used that particular overshoot expression because I had it handy. There is some discussion about how it works here:
https://www.motionscript.com/articles/bounce-and-overshoot.html#kf-overshoot
I think it's important to note that a complex expression is generally a combination of JavaScript syntax and the AE-specific extensions to the language that give you the ability to access comps, layers, properties, keyframes, etc. For the JavaScript part, I have always relied on David Flanagin's "JavaScript, The Definitive Guide" (3rd Edition for the Legacy Extendscript engine, 7th edition for the newer JavaScript engine). For the AE-specific stuff, I've always found the Expression Reference chapter in AE's help to be the best resource.
If you need help integrating the checkbox code into whatever overshoot code you're using, just post it here and we'll give you a hand.
Copy link to clipboard
Copied
Split the layer into respective sections with and without the expressions. No need to make it more complicated than that, especially since you have no expressions knowledge.
Mylenium
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more