Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Trying to tally keyframe values

  • Trying to tally keyframe values

    Posted by Rorick Howl on November 22, 2020 at 9:24 pm

    I’ve been struggling to make this work. Maybe someone here has an idea.

    I have two sliders. Slider A and Slider B.
    Slider A has several keyframes of various values.
    Every time it has a value of 5 I want to add 1 to the value of Slider B, but all I can seem to do is get it to “change” its value, not add to it. Once Slider A’s value changes, Slider B goes back to normal.
    As you can see what I’m trying to do is tally the number of times a specific value is represented. I intend to do this for several other values too, but for the sake of this example, this is enough.

    The closest thing I’ve found to this is a counter that counts the number of times a ball is in a certain part of the screen. It’s not quite the same, but the concept is pretty similar.
    https://creativecow.net/forums/thread/position-increment/

    I’m not much of a scripter, I just know enough to repurpose scripts and do a few simple things, so if anyone thinks they know how this can be done, have at it. 🙂

    Position increment

    Rorick Howl replied 5 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    November 22, 2020 at 11:29 pm

    It’s not too complicated if the expression can expect a slider A keyframe with the value of exactly 5 wherever it needs to tally:

    SliderA = effect("Slider A")("Slider");

    count = 0;

    for (i = 1; i <= SliderA.numKeys; i++){

    if (SliderA.key(i).time > time) break;

    if (SliderA.key(i).value == 5) count++;

    }

    count

    Otherwise, it gets more complex.

  • Rorick Howl

    November 23, 2020 at 12:19 am

    It works! I don’t understand everything the script is saying, but I know enough to change what it’s affecting and targeting. Thank you very much! This was a big help to me.

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