• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help translating from Legacy ExtendScript to JavaScript

Community Beginner ,
Oct 30, 2024 Oct 30, 2024

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!

TOPICS
Expressions , How to , Scripting

Views

110

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Oct 30, 2024 Oct 30, 2024

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) +
...

Votes

Translate

Translate
Enthusiast ,
Oct 30, 2024 Oct 30, 2024

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;

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 30, 2024 Oct 30, 2024

Copy link to clipboard

Copied

LOL That's a super simple fix! Works like a charm. Thanks for the help. 😛

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 30, 2024 Oct 30, 2024

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines