ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

if / else expression: Color Picker Changes the Opacity of a Pre Comp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Larisa Martin
if / else expression: Color Picker Changes the Opacity of a Pre Comp
on Feb 4, 2020 at 4:29:32 pm

I am trying to write an if / else statement for a project so if a color control is a certain color, it changes the opacity of a pre comp.

SO

if the color is #61CFC8 then the opacity of the pre comp is 100, but if it's any other color the opacity is 0.

This is the expression I have on the opacity of the layer I am trying to hide / show:

colorControl = comp("RHS_02_DaysOfTheWeek_16x9").layer("*PICK COLOR IN THIS LAYER*”);
if (colorControl.effect("COLOR 1")("COLOR") == #61CFC8) 100 else 0;


Return to posts index

Alex Printz
Re: if / else expression: Color Picker Changes the Opacity of a Pre Comp
on Feb 4, 2020 at 5:09:06 pm



colorControl = comp("RHS_02_DaysOfTheWeek_16x9").layer("*PICK COLOR IN THIS LAYER*”);
if (colorControl.effect("COLOR 1")("COLOR") == hexToRgb("61CFC8") 100 else 0;


Alex Printz
Mograph Designer


Return to posts index

Larisa Martin
Re: if / else expression: Color Picker Changes the Opacity of a Pre Comp
on Feb 4, 2020 at 5:28:46 pm

Just to make it easier for myself I moved everything to the same comp.

This is what I have on the opacity parameter of the layer I'm trying to hide/show:

if (thisComp.layer("*PICK COLOR IN THIS LAYER*").effect("COLOR 2")("Color") == hexToRgb("61CFC8") 100 else 0;

I am getting an "Error: SyntaxError: Unexpected number"


Return to posts index


Alex Printz
Re: if / else expression: Color Picker Changes the Opacity of a Pre Comp
on Feb 4, 2020 at 6:22:33 pm

whoops, lost a parentheses, also need to add a semicolon after the 100 and before the else for the new javascript engine.

if (thisComp.layer("*PICK COLOR IN THIS LAYER*").effect("COLOR 2")("Color") == hexToRgb("61CFC8")) 100; else 0;


Alex Printz
Mograph Designer


Return to posts index

Larisa Martin
Re: if / else expression: Color Picker Changes the Opacity of a Pre Comp
on Feb 4, 2020 at 6:42:37 pm

There are no more syntax errors in the code, but it's still not quite working right.
AE doesn't seem to be recognizing the color part of the code. So the opacity is just 0.

Larisa


Return to posts index

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