ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

multiple if else expressions

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Eric Freiler
multiple if else expressions
on Jul 29, 2020 at 6:26:00 pm

Trying to automate color swap using color select

looking to swap primary and secondary colors and also have the option to change either to a tertiary color

This is what I have so far for the primary color.
The second if statement negates the first. Believe I need something in between, but not sure what

Any help is appreciated

if (thisComp.layer("COLOR MASTER").effect("HOME SWAP")("Checkbox") == 0) {sampleImage([760,444],[1,1])} else
{
sampleImage([920,440],[1,1])
}
if (thisComp.layer("COLOR MASTER").effect("HOME PRI TO TER")("Checkbox") == 0) {sampleImage([760,444],[1,1])} else
{
sampleImage([930,536],[1,1])
}


Thanks Man


Return to posts index

Dan Ebberts
Re: multiple if else expressions
on Jul 29, 2020 at 8:03:09 pm

For a multi-conditional structure, you need an if, followed by a number of else if statements, and finally, an else. So your example might look like this:


if (thisComp.layer("COLOR MASTER").effect("HOME SWAP")("Checkbox") == 1) {
sampleImage([920,440],[1,1]);
}else if (thisComp.layer("COLOR MASTER").effect("HOME PRI TO TER")("Checkbox") == 1) {
sampleImage([930,536],[1,1]);
}else{
sampleImage([760,444],[1,1]);
}




Return to posts index

Eric Freiler
Re: multiple if else expressions
on Jul 30, 2020 at 12:45:52 pm

Thanks man. That was helpful

Running into another issue.

Checkbox works to swap primary and secondary colors and checkbox works to swap primary to tertiary....but if I swap primary and secondary....i'm unable to swap "new' primary color with tertiary.

Can there be a statement that says keep the initial swap and then add second swap?

Hopefully I'm explaining this right

Thanks in advance

Thanks Man


Return to posts index


Dan Ebberts
Re: multiple if else expressions
on Jul 30, 2020 at 2:05:53 pm

I'm not sure what you're asking. The expression can only have one result.

Dan



Return to posts index

Eric Freiler
Re: multiple if else expressions
on Jul 31, 2020 at 2:06:53 pm

Hey Dan

Not sure I explained in properly

Ended up figuring it out...needed to use && to make it work

Final expression below

Thanks

target = thisComp.layer("HOME SWATCH");
if (thisComp.layer("COLOR MASTER").effect("HOME SWAP")("Checkbox") == 1 && thisComp.layer("COLOR MASTER").effect("HOME PRI TO TER")("Checkbox") == 1)
target.sampleImage([930,530],[1,1]) else
if (thisComp.layer("COLOR MASTER").effect("HOME SWAP")("Checkbox") == 1 && thisComp.layer("COLOR MASTER").effect("HOME PRI TO TER")("Checkbox") == 0)
target.sampleImage([930,450],[1,1]) else
if(thisComp.layer("COLOR MASTER").effect("HOME SWAP")("Checkbox") == 0 && thisComp.layer("COLOR MASTER").effect("HOME PRI TO TER")("Checkbox") == 1)
target.sampleImage([930,530],[1,1]) else
target.sampleImage([760,444],[1,1])


Thanks Man


Return to posts index

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