Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Possible to use letters as values? if (val2 == a)

  • Possible to use letters as values? if (val2 == a)

    Posted by Anders Hattne on August 12, 2014 at 10:13 am

    Hello, I’m trying to work out if it’s possible to use letters as values for if conditions.
    The idea is to use the layer name (2nd letter) to control it’s anchor point.
    The below expression works if I replace a, b, c with numbers (1, 2, 3)..
    I’m a bit dumbfounded to why this wont work – don’t understand the parseInt toString functions really!


    lNme = thisLayer.name; //the name of the layer
    val1 = lNme.substr(0, 1); // first letter
    val2= lNme.substr(1, 1); // second letter

    if (val2 == a){[600, 600]}
    else if (val2 == b ){[300, 300]}
    else if (val2 == c ){[100, 100]}
    else{value}

    http://www.ardillamedia.com

    Anders Hattne replied 12 years ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    August 12, 2014 at 2:03 pm

    You have to include the letters in single or double quotes:

    if (val2 == “a”){[600, 600]}

    or,

    if (val2 == ‘a’){[600, 600]}

    Dan

  • Anders Hattne

    August 12, 2014 at 2:17 pm

    Thanks, another mind saved!
    Funnily I had tried that before and it didn’t work – possibly because I had left in a parseInt() somewhere before!

    http://www.ardillamedia.com

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