-
Using variables to build an expression in a script
In a script I’m working on, I have several layers stored as elements in an array. Later on in the script, I create a series of new layers. I want the value of certain parameters to be linked via expressions to the position values of the layers stored in my array. However, I’m not sure how to do this, because the syntax seems to be that you have to write the expression as a string in the script, like so:
app.project.activeItem.layer(“example layer”).transform.position.expression = “expression goes here as a string”;
I’m not sure how that works when part of what I want to include in my expression is a reference to an array. I’ve tried the following, which does not work:
app.project.activeItem.layer(“example layer”).transform.position.expression = layerArray[3] + “.transform.position;”;
Any ideas? I’m probably just approaching this wrong.