Skip to main content
Participating Frequently
August 4, 2024
Question

Expression errors

  • August 4, 2024
  • 1 reply
  • 902 views

Hi !

I got an expression, to align my Social Medial logo to a Solid, but when I do it, After effects say :

and, as I'm a complete beginner, I don't understant how to resolve my problem

Here is my expression :

s=thisComp.layer("Background").sourceRectAtTime();

hauteur=s.height/2;
thisComp.layer("Background").transform.yPosition-hauteur+thisComp.layer("Control").effect("Icon_width")("Slider")

 

Thanks by advance !

 

This topic has been closed for replies.

1 reply

Legend
August 4, 2024

Maybe on the Background layer, the dimensions are not separated (right-click on Position and choose Separate Dimensions), so Y Position is not accessible.

Try replacing yPosition with position[1]

s = thisComp.layer("Background").sourceRectAtTime();

hauteur = s.height / 2;
thisComp.layer("Background").transform.position[1] - hauteur + thisComp.layer("Control").effect("Icon_width")(1)

 

RolxesAuthor
Participating Frequently
August 4, 2024

Effectivly, after separate x & y on my Background, i don't have an error message anymore when I let my expression (So it's still the one I'll put on my first message)

But, now that's not a problem anymore, I'll see a new one

My logo is not align on the way I want, and the expression is from a video tutorial, so idk what to do

I want my anchor point stay always at the top-left of my Background, but i just don't know where it goes with this :

s=thisComp.layer("Background").sourceRectAtTime();

hauteur=s.height+thisComp.layer("Control").effect("Zoom_Icon")("Slider");

[960+hauteur/2,540-hauteur/2]

Again, thanks for your help ! 🙂

Legend
August 4, 2024

I would do something like this:

text anchor point:

[sourceRectAtTime().left, sourceRectAtTime().top + sourceRectAtTime().height / 2];

 

text position:

margin = thisComp.layer("Control").effect("margin")(1);
logo = thisComp.layer("logo");
logo.transform.position + [logo.sourceRectAtTime().width / 2] + margin