Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Pose 2 Pose with ONE SLIDER controlling a Layer with Multiple Sliders (And therefore: keyframes)

  • Wouter Dijkstra

    May 9, 2019 at 6:32 pm

    Haha Wauw! Filip! This works like a charm. Amazing work I must say!

    I copied and pasted and… it works. Piece of art! Thank you very much Filip! It works very interactive now.

    Would you like to explain your code a little? There is a lot of code I have no idea where it references to. Maybe I can learn from it.

  • Filip Vandueren

    May 9, 2019 at 6:55 pm

    Yes ☺

    global remark: I’ve use “a ? b : c;” a few times, which is a javacsript shorthand for simple if/then/else statements:

    if (a<10) { b= "smaller" } else { b = "larger" }

    is the same as

    b = (a<10) ? "smaller" : "larger";


    myIndex = 1; // number of the slider. (this is used in the comparison below)

    sl=thisComp.layer("Null 1").effect("Slider Control")("Slider");
    // this is the controlling slider that rules 'em all.

    // we want every slider to interpolate between 0 and 100
    // but if the original slider is not animated (has 1 or no keyframes) or we are before or after the first/last keyframe
    // then we shouldn't bother with calculating and just jump to the else{} statement
    if (sl.numKeys>1 && time>sl.key(1).time && time<sl.key(sl.numKeys).time) {

    nk = sl.nearestKey(time);
    prevK = nk.time<time ? nk : sl.key(nk.index-1);
    nextK = sl.key(prevK.index+1);
    // this is just the kind of messy code you need to find out what is the previous and what is the next keyframe of the main slider at this point in time
    // AE only has nearestKey() and that doesn't care if the nearest key is before or after this time.
    // that's why we're checking if nk (nearestKey) of the slider is before or after the current time,

    fromValue= (prevK.value == myIndex) ? 100 : 0;
    toValue= (nextK.value == myIndex) ? 100 : 0;
    // that's the main logic you needed: only my slider at full if that other slider points to "myIndex"
    // We check if both the previous and the next keyframe are equal to "myIndex"

    // Usually you would interpolate using the current time and the time of the keys
    // But that would mean the interpolation is always linear() or ease(), depending on what we hardcode.
    // Here I'm looking at the actual current value of the slider, and that tells me how fast it's going from it's previous keyframe's value to the next keyframes value, we map that to our two values (0 and 100 maybe)
    // However: linear (or ease) expects its second parameter to always be smaller than the third, so I check with an if-then statement if that is the case, if it's not, I re-order them.
    // linear (t, 10,0, 100,200) doesn't work -> linear (t, 0,10, 200,100) does work
    if (prevK.value<nextK.value) {
    linear(sl.value, prevK.value, nextK.value, fromValue, toValue);
    } else {
    linear(sl.value, nextK.value, prevK.value, toValue, fromValue);
    }
    // and we're done…

    } else {
    // or, if the slider is not animating; just check if its value == me.
    sl.value == myIndex ? 100 : 0;
    }

  • Wouter Dijkstra

    May 9, 2019 at 7:15 pm

    Hi Filip! Great that you explained so clearly. I must say I thought the thing I wanted was way easier (with the ValueAtTime thing, code I still ‘can manage’ ) But this is way more complex than I thought. I was able to pick up most of the code that you just taught me! Thanks for this.

Page 2 of 2

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