Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › multiple expressions on one track over time – How?

  • multiple expressions on one track over time – How?

    Posted by Xfrf.ru on May 6, 2007 at 7:25 pm

    Hi

    Is it possible in AFX 7 to have on one track at different times different expressions?

    For instance, I draw an L-shaped line with Write-On effect.
    for the horizontal segment at frames 1..15 Brush position takes only an X from the master null object, and for the second segment at frames 16..30 it should take only Y from the master null (motion tracker data).

    Is it possible to keyframe expressions? =)
    Or what is the alternative?

    Xfrf.ru replied 19 years, 4 months ago 4 Members · 5 Replies
  • 5 Replies
  • Filip Vandueren

    May 6, 2007 at 9:46 pm

    you can use if/else statements to switch between different expressions,
    trigger them by handcoding time,
    or by referencing to a slider that you can keyframe 1,2,3.
    or even using markers on the layer, whatever.

    like this:


    if (time<10) {
    // expression 1, will be calculated from 0-10 seconds
    } else if (time<15) {
    // expression 2 will be calculated from 10-15 seconds
    } else {
    // exression 3 will be calculated after 15 seconds
    }

    or


    temp = effect("Slider Control")("Slider");
    temp=Math.floor(temp.Value); // round of the values so we don't have problems with inbetween integer values

    switch temp {
    case 0:
    // expression 1
    case 1:
    // expression 2
    case 2:
    // expression 3
    default:
    // default expression
    }

    I used the switch syntax for fun here, it's a different way of testing one value against a set of possibilities.

  • Dan Ebberts

    May 7, 2007 at 12:06 am

    Using switch is a cool way to do it. You could combine that with code to get the index of the most recent marker, then you could set it up so that you just need to drop a layer marker wherever you wanted the next expression to start.

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

    switch (n) {
    case 1:
    // expression 1
    break;
    case 2:
    // expression 2
    break;
    case 3:
    // expression 3
    break;
    default:
    // default expression (no markers or more than 3)
    }

    Dan

  • Xfrf.ru

    May 7, 2007 at 1:16 pm

    Thank You Filip!
    This helps. I did not realise expressions can be more than one line constructions with branching! )

  • Mike Clasby

    May 7, 2007 at 6:14 pm

    I like all three methods, although the Marker solution is very handy for me..

    Thanks for all.

  • Xfrf.ru

    May 7, 2007 at 6:28 pm

    Dan, thank you for the advanced solution!

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