Skip to main content
Inventsable
Legend
Nov 29, 2019 9:56 PM UTC
Question

What ECMA standard do expressions support?

Hi all. I know that for scripting .jsx files, it's ECMA 262, but after taking a long break from animating to learn all about coding and scripting, I've recently come back and was shocked to see that I can use this in an expression:

 

Object.keys(data).forEach(key => {
  console.log(key)
})

 

And this throws no errors. Obviously this has no effect because AE doesn't have a console (...right? I wish it did. Can I print data from expressions anywhere, to see coordinate data, etc?) but the implication of Object.keys, Array.prototype.forEach, and arrow functions leads me to think this is at least ECMA2015/ES6?

 

Is it fair to assume these actually work, or is this just some bug where the expression validation doesn't catch them as errors?

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Inventsable
Legend
Nov 29, 2019 10:39 PM UTC

What I'm trying to do is manually recreate the bezier handles of any given pathPoint. This does work inside a Shape Layer's Path as an expression to generate a line between the tangentIn and it's target anchor:

const parentLayer = thisComp.layer("line");
const parentPath = parentLayer.content("line").content("Path 1").path;
let vertices = [0,1]

const data = {
  position: parentLayer.transform.position,
  anchor: parentLayer.transform.anchorPoint,
  vertex: parentPath.points()[1],
  tangent: parentPath.inTangents()[1],
};

createPath(
  vertices.map((index, i) => {
    let offsetX = 0;
    let offsetY = 0;
    Object.keys(data).forEach((val, e) => {
      if (i < 1 || val !== "tangent") {
        offsetX = offsetX + data[val][0];
        offsetY = offsetY + data[val][1];
      }
    });
    return [offsetX, offsetY];
  }),
  [],
  [],
  false
);

 

Which is awesome. ES6 Array methods

Translate
Martin_Ritter
Legend
Nov 30, 2019 12:08 AM UTC

As far as I know there is no console in AE - I'm always debugging with text layers 😞

 

*Martin

Translate