Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions using if else to set a variable

  • using if else to set a variable

  • Adam Greenberg

    October 19, 2022 at 2:16 pm

    Hi everyone, simple question I think,

    Is my 5th line of code correct ?

    I am trying to set this variable into a complicated expression, so I did not bother to paste the whole thing, only the problematic line.

    Basically I want ”a” to be a variable depending on which layer in the precomp is turned on;


    title2=precomp1.source.layer(“title 2 lines”);



    if(comp(“precomp”).layer(“title”).active) var a = b else var a = c;

    Thanks so much

  • Dan Ebberts

    October 19, 2022 at 3:20 pm

    The JavaScript engine won’t accept if/else on a single line in that format. I’d do it like this:

    a = comp("precomp").layer("title").active ? b : c;
  • Adam Greenberg

    October 19, 2022 at 4:14 pm

    oh ok. Thanks so much Dan

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