Skip to main content
Patrick Guillouset
Inspiring
April 2, 2020
Answered

Expression error on the position of the anchor point

  • April 2, 2020
  • 1 reply
  • 4158 views

Hello ! I am a beginner in expressions, and to learn and understand I practice expressions like this found on School of motion

 

a=thisComp.layer("Text").sourceRectAtTime();

height=a.height;

width= a. width;

top=a.top;

left=a.left;

x=left;

y=top+height

[x,y];

This code should fix the anchor point at the bottom left of the text layer, but AE sends me back:

Error at line 8 in the “anchor point” property of the layer (“Text”) in the composition 6. property or method named “y” in the class “global” not found or non-existent ...

Can you tell me why?

This topic has been closed for replies.
Correct answer Rick Gerard

You left the semicolon off the end of line 7 so y was never defined. Nothing but a typo.

 

if you the layer reference to thisLayer you won't have to worry about the text layer name. There is also no need to define the width. I have a similar expression saved as an animation preset:

 

txtLyr = thisLayer.sourceRectAtTime();
height = txtLyr.height;
top = txtLyr.top;
left = txtLyr.left;
x = left;
y = top + height;

[x,y]

 

 That's a little cleaner and you never have to worry about the layer name.

 

1 reply

Rick GerardCommunity ExpertCorrect answer
Community Expert
April 2, 2020

You left the semicolon off the end of line 7 so y was never defined. Nothing but a typo.

 

if you the layer reference to thisLayer you won't have to worry about the text layer name. There is also no need to define the width. I have a similar expression saved as an animation preset:

 

txtLyr = thisLayer.sourceRectAtTime();
height = txtLyr.height;
top = txtLyr.top;
left = txtLyr.left;
x = left;
y = top + height;

[x,y]

 

 That's a little cleaner and you never have to worry about the layer name.

 

Patrick Guillouset
Inspiring
April 3, 2020
Thank you very much ! i will pay attention to that now