Forums › Adobe After Effects Expressions › After Effects unexpected error
Tagged: Basic
-
After Effects unexpected error
-
Obed Ampong
February 6, 2023 at 8:45 pmHello,
I am trying to use sourceRect to align text on Essential Graphics Template but it keep resulting unexpected error. Please could someone help me out? Thank you in advanced.
Below is the script
a = thisComp.layer(“TEXT”).sourceRectAtTime();
height = a.height;
width = a.width;
top = a.top;
left = a.left;
if (thisComp.layer(thisComp.layer(“Null 1”).effect(“ALIGNMENT”)(“Menu”)==1)
{
x = left;
}
else if (thisComp.layer(“Null 1”).effect(“ALIGNMENT”)(“Menu”)==2)
{
x = left + width / 2;
}
else {
x = left + width;
}
[x,top + height]
Regards
Obed
-
Dan Ebberts
February 6, 2023 at 9:43 pmOne thing I see is that this line appears to be messed up:
if (thisComp.layer(thisComp.layer("Null 1").effect("ALIGNMENT")("Menu")==1)
Also, you might have issues using height and width as variable names, because those are layer attributes.
Beyond that, what is the error message you’re seeing?
-
Manuel Moellmann
February 6, 2023 at 10:36 pmas dan already mentioned:
if (thisComp.layer(thisComp.layer(“Null 1”).effect(“ALIGNMENT”)(“Menu”)==1)
–> if (thisComp.layer(“Null 1”)
and maybe not really a problem but i would suggest to add some spaces to the condition:
(“Menu”) == 1 -
Obed Ampong
February 7, 2023 at 3:33 amHi, Dan and Manuel. Thank you very much. It’s a shame I have been struggling with this and I didn’t notice it.
Log in to reply.