Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Compare two values

  • Compare two values

    Posted by Tristan Nieto on February 25, 2009 at 11:37 am

    Hi,

    Is there an expression that can operate like a comparison node, as in compare 2 values and pick one.

    For example – compare 2 layers’ x-position values, pick the larger one and set that layer’s opacity to 0%.

    Or something to that effect?

    Cheers

    Tristan Nieto replied 17 years, 2 months ago 2 Members · 3 Replies
  • 3 Replies
  • Filip Vandueren

    February 25, 2009 at 1:41 pm

    Both layers would need an expression applied to opacity:

    1st layer:

    l1=thisLayer;
    l2=thisComp.layer("second layer");

    if (l1.position[0]>l2.position[0]) {
    100;
    } else {
    0;
    }

    The 2nd layer could just have an expression for opacity like:

    l2=thisComp.layer("first layer");
    100 - l2.opacity;

    or you can re-use the first expression and change the first two lines to:

    l1=thisComp.layer("first layer");
    l2=thisLayer;

    if (l1.position[0]>l2.position[0]) {
    100;
    } else {
    0;
    }

  • Filip Vandueren

    February 26, 2009 at 1:32 am

    Obviously, in that last expression 100 and 0 need to be reversed


    l1=thisComp.layer("first layer");
    l2=thisLayer;

    if (l1.position[0]>l2.position[0]) {
    0;
    } else {
    100;
    }

  • Tristan Nieto

    February 26, 2009 at 12:07 pm

    Works like a charm.

    Nice work Filip, thanks for helping out.

    Tristan

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