ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Over riding two If/Else statements

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Glenn Tak
Over riding two If/Else statements
on Apr 14, 2020 at 7:13:15 pm

I have a project which requires switching back and forth between 2 y-positions depending on the input data. Occasionally there is a need to manually adjust for a third line or special characters so I want to keep a 'value' option available to me.

I have set up with 2 check boxes connected to the y-position.

Each statement works individually but the second if/else statement seems to nullify the first

What am I missing?


Thanks

Line1 = (effect("Single Line Position")("Checkbox"))
Line2 = (effect("2 Line Position")("Checkbox"))

if(Line1 == true)1666.5;
else value;

if(Line2 == true)1582.5;
else value;


______________________

"Nothing is Easy"
Jethro Tull


Return to posts index

Dan Ebberts
Re: Over riding two If/Else statements
on Apr 14, 2020 at 7:37:58 pm

You could combine them like this:

Line1 = effect("Single Line Position")("Checkbox").value;
Line2 = effect("2 Line Position")("Checkbox").value;

if(Line1)1666.5
else if(Line2)1582.5
else value

Note that Line 1 will have priority if both checkboxes are checked.


Dan



Return to posts index

Glenn Tak
Re: Over riding two If/Else statements
on Apr 14, 2020 at 8:24:29 pm

You are Da Man.

Thanks. No matter how many tutorials I do, there is always something that escapes me.

T Rex

______________________

"Nothing is Easy"
Jethro Tull


Return to posts index


Glenn Tak
Re: Over riding two If/Else statements
on Apr 15, 2020 at 5:55:29 pm

A question....

Does the code: Line1 = effect("Single Line Position")("Checkbox").value;

Assume the .value is true? Is that a default for a boolean .value?

If not, don't know how the further code : if(Line1)1666.5: knows that the box is checked.

I know other codes have default assumptions.

Thanks again for the help.

T

______________________

"Nothing is Easy"
Jethro Tull


Return to posts index

Dan Ebberts
Re: Over riding two If/Else statements
on Apr 15, 2020 at 6:00:30 pm

Yes, the value of a checkbox evaluates to true if checked, false if unchecked.

Dan



Return to posts index

Glenn Tak
Re: Over riding two If/Else statements
on Apr 15, 2020 at 6:10:43 pm

Sorry for bugging you again... I think I am a little confused about

if(Line1)1666.5

If the checkbox for the Line 1 variable is unchecked, it would be false.

Wouldn't the above line then interpret that an unchecked box would result in 1666.5?

Essentially...

if(effect("Single Line Position")("Checkbox")==false)1666.5

Or does a false value simply ignore the statement?

______________________

"Nothing is Easy"
Jethro Tull


Return to posts index


Dan Ebberts
Re: Over riding two If/Else statements
on Apr 15, 2020 at 6:20:38 pm

If variable Line1 is false (corresponding checkbox unchecked), it skips the 1666.5 and moves to the else if part. If variable Line1 is true, it accepts 1666.5 as the result, and ignores the else if and else parts.

Dan



Return to posts index

Glenn Tak
Re: Over riding two If/Else statements
on Apr 15, 2020 at 6:23:32 pm

Thanks. That makes sense.

I appreciate your time and wisdom.

______________________

"Nothing is Easy"
Jethro Tull


Return to posts index

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