Copy link to clipboard
Copied
Hi all
Maybe I don't know something...
You can write an expression for the position of a layer in different ways. For example like this
var TargetL = thisComp.layer("GradComp")
[TargetL.width, TargetL.height]
or so
[thisComp.layer("GradComp").width, thisComp.layer("GradComp").height]
When you write it for the first time, the application shows an error
TypeError: Cannot read properties of undefined (reading 'width')
But with the second version of writing, such an error does not occur...
What is the difference???
Copy link to clipboard
Copied
Be sure to end the token line with a semicolon (;)
Copy link to clipboard
Copied
@AnyON has it right, the programming language in After Effects is a cut down version of Javascript. Semicolons are used to end a statement in Javascript, as otherwise it reads as:
var TargetL = thisComp.layer("GradComp")[TargetL.width, TargetL.height]
Which AE would try to take as create a new variable, called TargetL and make it equal to a values in an array called thisComp.layer("GradComp") and those values are TargetL's width and height, which we've just made - in other words something not possible to process.