Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions if then else snafu

  • if then else snafu

    Posted by Pierre Guiet on January 29, 2007 at 7:36 pm

    Hello,

    I’m making an altimeter and I have a needle revolving around a face
    I have a scroll wheel with 10 numbers on it (essentially) that match the rotation of the needle
    trouble is my graphic has only 10 numbers 0 thru 9
    I would like to reset it once it makes one complete revolution or in this case
    once I have translated the graphic all the way to the top. I would like to put it back
    in its starting position

    The following scripts works great until I get to the top of the sequenced numbers graphic
    it just keeps going right off the screen.
    I thought an “if then” statement would work.
    I don’t get any errors with this but I dont’ get the behavior I’m looking for either.

    Thanks for your help.

    //Use the needle to position the numbers
    // to get the .72 I divided 36 degrees the amount it takes to get to 1 by 50 pixels the height of the letter box

    //by the height of the letterbox 50 pixels
    yPosition = thisComp.layer(“NEEDLE”).transform.rotation/0.72;
    // set the yposition and test to see if it goes out of range if so restart it
    pt = [value[0], yPosition-105]
    if (pt > 395) pt = -105;
    pt

    Pierre Guiet replied 19 years, 6 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    January 29, 2007 at 9:09 pm

    See if this gets you closer:

    yPosition = thisComp.layer(“NEEDLE”).transform.rotation/0.72%360;
    [value[0], yPosition-105]

    Dan

  • Pierre Guiet

    January 29, 2007 at 9:53 pm

    Dan,
    That is wonderful. Turns out when I change number 360 to the height of my graphic minus the adjustment for placing the layer
    500 works perfectly.

    I couldn’t find the % symbol in the help file.
    Can you use this in other contexts?

    thanks again
    bn

  • Dan Ebberts

    January 29, 2007 at 10:43 pm

    % is the JavaScript modulus operator. x%y returns the remainder that results from dividing x by y. Very useful for translating a continuously growing value into a cyclic one.

    Dan

  • Pierre Guiet

    January 29, 2007 at 11:03 pm

    thanks

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