Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions if / else expression: Color Picker Changes the Opacity of a Pre Comp

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

    Posted by Larisa Martin on February 4, 2020 at 4:29 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;

    Larisa Martin replied 6 years, 2 months ago 2 Members · 4 Replies
  • 4 Replies
  • Alex Printz

    February 4, 2020 at 5:09 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

  • Larisa Martin

    February 4, 2020 at 5:28 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”

  • Alex Printz

    February 4, 2020 at 6:22 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

  • Larisa Martin

    February 4, 2020 at 6:42 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

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