Copy link to clipboard
Copied
Hello, I recently upgraded my AfterEffects from a really old version, and some of the code that I had previously used in a lot of templates and projects is now no longer working. After some troubleshooting, I found that I can make it work if I switch my project to use Legacy ExtendScript instead of JavaScript. Is anyone able to help me translate my code so that I can use it in a JavaScript project?
(I don't even remember where the original code for this came from, I just found it somewhere on an old internet forum.)
var L = thisLayer;
var easing = 5 + thisComp.layer("Controller").effect("Easing")(1); // Slider determines easing amount, 1 is linear
var val = value;
if (numKeys > 0){
n = nearestKey(time).index;
if (time < key(n).time) n--;
if (n > 0 && n < numKeys){
val = easeValues(key(n).time,key(n+1).time,key(n).value,key(n+1).value,easing);
}
}
val
function easeValues(startT, endT, startV, endV, ease) {
var dur = endT - startT
normalizedEasing =(Math.ceil(ease/2) * 2)-1;
var easedTime = easeTime(time - startT, 0, 100, dur);
return linear(easedTime, 0, 100, startV, endV);
}
function easeTime(t, b, c, d) {
if ((t/=d/2) < 1) {
return c/2*Math.pow(t, normalizedEasing) + b;
} else {
return c/2*((t-=2)*Math.pow(t, normalizedEasing -1) + 2) + b;
}
}
Thank you, and have a nice day!
Maybe try placing the functions at the beginning of the code.
function easeValues(startT, endT, startV, endV, ease) {
var dur = endT - startT;
normalizedEasing =(Math.ceil(ease/2) * 2)-1;
var easedTime = easeTime(time - startT, 0, 100, dur);
return linear(easedTime, 0, 100, startV, endV);
}
function easeTime(t, b, c, d) {
if ((t/=d/2) < 1) {
return c/2*Math.pow(t, normalizedEasing) + b;
}
else {
return c/2*((t-=2)*Math.pow(t, normalizedEasing -1) + 2) +
...
Copy link to clipboard
Copied
Maybe try placing the functions at the beginning of the code.
function easeValues(startT, endT, startV, endV, ease) {
var dur = endT - startT;
normalizedEasing =(Math.ceil(ease/2) * 2)-1;
var easedTime = easeTime(time - startT, 0, 100, dur);
return linear(easedTime, 0, 100, startV, endV);
}
function easeTime(t, b, c, d) {
if ((t/=d/2) < 1) {
return c/2*Math.pow(t, normalizedEasing) + b;
}
else {
return c/2*((t-=2)*Math.pow(t, normalizedEasing -1) + 2) + b;
}
}
var L = thisLayer;
var easing = 5 + thisComp.layer("Controller").effect("Easing")(1);
// Slider determines easing amount, 1 is linear
var val = value;
if (numKeys > 0){
n = nearestKey(time).index;
if (time < key(n).time) n--;
if (n > 0 && n < numKeys){
val = easeValues(key(n).time,key(n+1).time,key(n).value,key(n+1).value,easing);
}
}
val;
Copy link to clipboard
Copied
LOL That's a super simple fix! Works like a charm. Thanks for the help. 😛
Copy link to clipboard
Copied
This is helpful if you need to convert any other legacy code to the new engine:
https://helpx.adobe.com/after-effects/using/legacy-and-extend-script-engine.html