Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions how to express “if certain value is among some array than..”?

  • how to express “if certain value is among some array than..”?

    Posted by Vojtěch Palme on January 13, 2013 at 4:19 pm

    I want one layer to appear only if the current date is same as one of dates in array.
    I tryed:
    D = new Date(Date(0));
    today = D.getDate() + "/" + (D.getMonth()+1);
    vis = transform.opacity;
    fullMoon = ["27/3","25/4","25/5","23/6","22/7","21/8","19/9","19/10","17/11","17/12"];

    if (today == fullMoon)
    vis = 100
    else
    vis = 0;

    but it does nothing.. guess == is not rly what Im looking for.

    Dan Ebberts replied 13 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Vojtěch Palme

    January 13, 2013 at 4:30 pm

    Alright I got an answer on different forum. It’s:

    for(var i = 0; i < fullM.length; i++) {
    if(today == fullMoon[i]) {
    100;
    break;
    } else {
    0;
    break;
    }
    }

  • Dan Ebberts

    January 13, 2013 at 6:31 pm

    I think the “break” in the else clause will cause your loop to terminate early if it doesn’t match the first element of the array. I’d do it like this:


    result = 0;
    for(var i = 0; i < fullMoon.length; i++) {
    if(today == fullMoon[i]) {
    result = 100;
    break;
    }
    }
    result

    Dan

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