Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Multiple conditions for text opacity relative to number of lines

  • Multiple conditions for text opacity relative to number of lines

  • Gregory Wannwitz

    October 25, 2021 at 9:51 am

    Hello

    I have difficulties to solve problems with a project that is a little bit complex.

    *I have a text layer used as “source text”.

    * 3 text layers, for 1 line / 2 lines / 3 lines text, with opacity linked with the number of lines in the “source text”. I control the text with essential graphics. The size of the text for 1 line or 2/3 lines is different.

    * I have a dropdown menu too, used to switch between the text, or a logo, or a Live logo using the opacity parameter.

    Here is the problem, when I choose “logo” or “live” in the dropdown menu, the text layers do not disappear because they are also linked to the lines number. And I need to have only “text”, or only “live”, or only “logo”.

    I need to use a if/or/and / else statement, but I can not find the right way of writing it.

    For example, I wrote this in the opacity of the 2 lines text layer:

    ===================================

    OPAC = transform.opacity.value;

    dropMenu2 = comp(“ES_TITLE_CUSTOM”).layer(“CLOSER_CUSTOM 4”).effect(“PART 2”)(1).value;

    switch ( dropMenu2 )

    {

    case 3: [100]

    break;

    default: [0]

    };

    thisComp.layer(“EVENT NAME”).text.sourceText.split(‘\r’).length === 2 || thisComp.layer(“EVENT NAME”).text.sourceText.split(‘\3’).length > 1 ? OPAC : 0

    ===================================

    As you can see the opacity is controlled by the dropdown menu and by number of lines, with so many conditions I do not find how to make a correct code.

    You can also find the project, because it is not easy to explain it in details.

    If someone can help me, it would be great help.

    Thanks in advance.

  • Dan Ebberts

    October 25, 2021 at 8:39 pm

    Generally, if you have multiple conditions to evaluate, you can just drop the individual results into boolean variables and then evaluate them all in the final line of the expression. This is just an example, I have no idea if it actually does what you need:

    dropMenu2 = comp("ES_TITLE_CUSTOM").layer("CLOSER_CUSTOM 4").effect("PART 2")(1).value;

    splitText = thisComp.layer("EVENT NAME").text.sourceText.split('\r');

    cond1 = dropMenu2 == 3;

    cond2 = splitText.length > 1;

    (cond1 || cond2) ? 100 : 0

  • Gregory Wannwitz

    October 26, 2021 at 8:23 am

    Thank you very much !

    With your solution it is easier to understand and it works !

    I just start to use expressions and I do not have the correct and logical approach to that. And I do not know yet a lot of terms.

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