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

grammar of expressions

Engaged ,
Feb 14, 2024 Feb 14, 2024

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

 

Error.png

 

What is the difference???

TOPICS
Expressions

Views

204

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
Engaged ,
Feb 14, 2024 Feb 14, 2024

Copy link to clipboard

Copied

Be sure to end the token line with a semicolon (;)

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 ,
Feb 15, 2024 Feb 15, 2024

Copy link to clipboard

Copied

LATEST

@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.

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