Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Multiple if statements

  • Multiple if statements

    Posted by Mio Tanaka on December 18, 2012 at 2:25 am

    Hello, I’m a relatively new to expressions. I tried to make an expression which the same animation starts from multiple layer marker switches, wanting it to be repeated over and over again.

    I’ve tried something like below. Now I know ‘||’ stops working after one of its if statements, but I wonder if there’s a way to do this.

    Also I wanted it to be repeated, say, every 3 seconds. Is there a way to do this?

    var keyTime = key(2).time-key(1).time;
    var m1 = thisLayer.marker.key(1).time;
    var m2 = thisLayer.marker.key(2).time;

    if (time>m1 || time>m2);
    linear(time,m1,m1+keyTime,key(1).value,key(2).value)

    Mio Tanaka replied 13 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    December 18, 2012 at 3:35 am

    This should work for the markers:


    n = 0;
    m = marker;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (m.key(n).time > time) n--;
    }

    keyTime = key(2).time-key(1).time;
    t = (n > 0) ? (time - m.key(n).time) : 0;
    linear(t,0,keyTime,key(1).value,key(2).value)

    and this one should repeat every 3 seconds:

    t = time%3;
    keyTime = key(2).time-key(1).time;
    linear(t,0,keyTime,key(1).value,key(2).value)

    Dan

  • Mio Tanaka

    December 18, 2012 at 6:06 am

    Thank you so much for them!

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