Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Changing variable value based on multiple conditions

  • Changing variable value based on multiple conditions

  • Kevin Snyder

    May 7, 2020 at 6:48 am

    I’m trying to change the value of a variable based on four different conditions so that in each condition the value of the variable will be different. I’m trying the code below, but running into some errors. Is there a better way to tackle this?

    if (myProp && !altKey)
    {var myControl = myEffect + " " + myGroup + " " + "-" " " myLayerName}
    else if (!myProp && altKey)
    {var myControl = myEffect}
    else if(!myProp && !altKey)
    {var myControl = myEffect + " " + "-" " " myLayerName}
    else if (myProp && altKey)
    {var myControl = myEffect + " " + myGroup};

  • Robert Müller

    May 7, 2020 at 8:27 am

    Hi, just so that I understand correctly: The four conditions HAVE to be based on the 2 different variables myProp and altKey and their different states? Can you share some more details why 1 variable wouldnt be enough?

  • Andrei Popa

    May 7, 2020 at 11:14 am

    You can’t have strings like that without + between them. Try this

    if (myProp && !altKey) {
    var myControl = myEffect + " " + myGroup + " " + "-" + " " + myLayerName;
    } else if (!myProp && altKey) {
    var myControl = myEffect;
    } else if (!myProp && !altKey) {
    var myControl = myEffect + " " + "-" + " " + myLayerName;
    } else if (myProp && altKey) {
    var myControl = myEffect + " " + myGroup;
    }

    Andrei
    My Envato portfolio.

  • Kevin Snyder

    May 7, 2020 at 7:27 pm

    Thank you for the feedback Andrei. I appreciate it!

Viewing 1 - 4 of 4 posts

Log in to reply.

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