Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Using && in if/else statements

  • Using && in if/else statements

    Posted by Dennis Cheung on December 18, 2020 at 12:32 am

    Hi

    I have slider control attached to a null object aimed to convert collected values based on the content of two text fields. I’m using the && symbol to bring both sides of my statement together.

    In plain English:

    if text1 and text2 don’t say “the magic word” : slider value = 0

    if text1 says “the magic word,” but text2 doesn’t: slider value = 1

    if text1 doesn’t says “the magic word,” but text2 does: slider value = 2

    if text1 and text2 both say “the magic word” : slider value = 3

    My coding:

    away = thisComp.layer(“AWAY TEAM FEEDBACK”).text.sourceText;

    home = thisComp.layer(“HOME TEAM FEEDBACK”).text.sourceText;

    if (away != “TEAM1” && home != “TEAM1”)

    {

    0} else

    if (away = “TEAM1” && home != “TEAM1”)

    {

    1} else

    if (away != “TEAM1” && home = “TEAM1”)

    {

    2} else

    if (away = “TEAM1″&& home = “TEAM1”)

    {

    3} else

    {100}

    THANKS FOR YOUR TIME

    Dan Ebberts replied 5 years, 4 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    December 18, 2020 at 12:45 am

    For one thing, you’re using = instead of == to check for equality.

    Dan

  • Dennis Cheung

    December 18, 2020 at 1:12 am

    Hi Dan

    I used == (and !==) as well, but my slider value is stuck at 0.

    away = thisComp.layer(“AWAY TEAM FEEDBACK”).text.sourceText;

    home = thisComp.layer(“HOME TEAM FEEDBACK”).text.sourceText;

    if (away !== “TEAM1” && home !== “TEAM1”)

    {

    0} else

    if (away == “TEAM1” && home !== “TEAM1”)

    {

    1} else

    if (away !== “TEAM1” && home == “TEAM1”)

    {

    2} else

    if (away == “TEAM1” && home == “TEAM1”)

    {

    3} else

    {100}

  • Dan Ebberts

    December 18, 2020 at 1:40 am

    Try changing the first two lines to this:

    away = thisComp.layer("AWAY TEAM FEEDBACK").text.sourceText.value;

    home = thisComp.layer("HOME TEAM FEEDBACK").text.sourceText.value;

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