ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Changing variable value based on multiple conditions

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kevin Snyder
Changing variable value based on multiple conditions
on May 7, 2020 at 6:48:40 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};


Return to posts index

Robert Müller
Re: Changing variable value based on multiple conditions
on May 7, 2020 at 8:27:15 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?


Return to posts index

Andrei Popa
Re: Changing variable value based on multiple conditions
on May 7, 2020 at 11:14:09 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.


Return to posts index


Kevin Snyder
Re: Changing variable value based on multiple conditions
on May 7, 2020 at 7:27:59 pm

Thank you for the feedback Andrei. I appreciate it!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]