Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects “Illegal” variable names in expressions?

  • “Illegal” variable names in expressions?

  • Matthew Belinkie

    September 19, 2022 at 10:37 pm

    Hi guys. So this expression for Anchor Point works as expected when applied to a text layer, keeping the Anchor Point on the center right:

    a = thisLayer.sourceRectAtTime(4);
    H = a.height;
    W = a.width;
    T = a.top;
    L = a.left;
    [L+W,T+H/2]

    However, this expression does NOT work for some reason.

    a = thisLayer.sourceRectAtTime(4);
    height = a.height;
    width = a.width;
    top = a.top;
    left = a.left;
    [left+width,top+height/2]

    I suspect the problem is that certain words (“height” “width” “top” and “left” for instance) can’t be used as variables, but that’s just a guess. Anybody know what’s going on here? Thanks.

  • Filip Vandueren

    September 20, 2022 at 9:46 am

    You are correct.

    For example height gets interpreted as thisLayer.height and you can’t assign a value to that.

    So it’s best to avoid variable names that are property and method names of thisComp, thisLayer, thisProperty

  • Matthew Belinkie

    September 20, 2022 at 3:20 pm

    Thanks a lot. I was actually led astray by this School of Motion guide:

    https://www.schoolofmotion.com/blog/anchor-point-expressions-in-after-effects

    It explains the expressions very well except the variables they use simply won’t work right. Hard to believe they missed that, but just changing the variables to simple letters corrects it.

Viewing 1 - 3 of 3 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy