Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions [SOLVED] Color value doesn't work with if else statement

  • [SOLVED] Color value doesn't work with if else statement

  • Remi Monedi

    September 13, 2020 at 1:33 pm

    Hi!

    I tried to do a simple thing and I don’t understand why it is not working…
    I have a color control set to white ( [1,1,1,1] ) and a slider which should display “999” when the color is white. I made this expression :

    if (effect(“Color Control”)(“Color”)[0] == [1,1,1,1]) 999

    else 0

    And it doesn’t work! I tried in rgb, in hex, i tried to change the [1,1,1,1] to another white Color Control, nothing! Am I missing something here?

  • Remi Monedi

    September 13, 2020 at 1:40 pm

    Ok. After looking some more at some code found on this forum, I found I just had to add [0] after the color value. Then to work properly, the expression should be :

    if (effect(“Color Control”)(“Color”)[0] == [1,1,1,1][0]) 999

    else 0

    Sorry for the double post…

  • Dan Ebberts

    September 13, 2020 at 2:13 pm

    <div>If you do that, you’re only checking the red channel. Maybe something like this:</div>

    c = effect("Color Control")("Color").value;

    if (c[0] == 1 && c[1] == 1 && c[2] == 1)

    999

    else

    0

    or this:

    c = effect("Color Control")("Color").value;

    white = [1,1,1,1];

    if (JSON.stringify(c) == JSON.stringify(white))

    999

    else

    0

    Dan

Viewing 1 - 3 of 3 posts

Log in to reply.

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