Copy link to clipboard
Copied
I'm writing code to be used both as javascript on a web page, and as an AE expression, but I'm finding errors occur (regardless of whether the project is set to "Legacy ExtendScript" or "JavaScript"). I've consulted this Adobe reference page to figure out what issues I'll encounter, but, even after clicking through the links, it's still not clear.
An example of an issue I've encountered is the "ease" expression. In AE, the only function available seems to be "ease()", whereas in JS, "ease()" doesn't seem to work, and instead there are an array of ease expressions like "easeInOutSine()". I don't see anything mentioned about these functions in the Adobe reference page.
I have two questions: 1) Is there a clearer reference to learn the differences between the two languages? and 2) Does anyone have any advice for writing code that will work in both environments?
Thanks!
Well, I'd say if it's listed in the expression language reference (like ease() and linear() are), it's not part of JavaScript. Other than that, I'm not sure what to suggest.
Copy link to clipboard
Copied
If you look at the expression language reference in the AE help, pretty much all of that consists of AE-specific extensions to JavaScript that won't work on a web page. It's possible, but not often useful, to construct an expression out of pure JavaScript, but the real power of expressions lies in those AE-specifc extensions. Core JavaScript is the glue that holds it all together, but not particulary useful on its own.
Copy link to clipboard
Copied
Thanks for the reply, but I'm not having any problems with extensions beyond what's available in JavaScript, I'm having problems with functions not being the same - such as the "ease" functions I mentioned. I'm hoping to find some reference for differences like these. Do you know of any?
Copy link to clipboard
Copied
Well, I'd say if it's listed in the expression language reference (like ease() and linear() are), it's not part of JavaScript. Other than that, I'm not sure what to suggest.
Copy link to clipboard
Copied
Oh, that's good to know. Thanks! And anything for the other direction, i.e. which JavaScript functions, like easeInOutSine(), won't work when used in AE?
Copy link to clipboard
Copied
As far as I know, JavaScript doesn't have any ease functions. There may be third-party libraries that have them, but expressions wouldn't recognize anything that's not actually in the JavaScript language. The JavaScript expression engine is based on ECMAScript 2018 which has a lot more modern methods, objects, and syntax than the older Legacy ExtendScript expression engine, which is based on ECMAScript 3 (1999). I doubt that you're going to find the reference you're looking for.