Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions I want a text layer to change based on my marker index

  • I want a text layer to change based on my marker index

    Posted by Lauren Roundy on August 1, 2019 at 11:09 pm

    I currently have my source text linked to a slider and rounded to the nearest whole number. I just want my slider value (or the text in my text layer) to display a single whole number at any given time, but I’d like to control what that number is based on markers on another layer.

    If the marker is the first marker on the layer, I want the text layer (or slider number) to be 1. If it’s the second marker on that layer, I want the text layer to be 2 etc…

    Actually, I want it to be the index of the markers on the layer +1, because for reasons I don’t want to get into, I have a “dummy” marker at the start of my comp (actually 20 frames before my comp starts). So, I technically want marker #2 to display 1, and then marker #3 to display 2 and so on.

    Thanks for the help!

    Dan Ebberts replied 7 years, 1 month ago 2 Members · 4 Replies
  • 4 Replies
  • Lauren Roundy

    August 1, 2019 at 11:13 pm

    Btw, here is my current code. But I don’t want it based on the “nearest” key, I want it based exactly on the key or marker. In other words, I want the number of my slider to change exactly when there’s a marker on the other layer.

    thisComp.layer("Death_icon 2").marker.nearestKey(time).index

  • Dan Ebberts

    August 2, 2019 at 12:21 am

    Probably like this:

    m = thisComp.layer("Death_icon 2").marker;
    n = 0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (m.key(n).time > time) n--;
    }
    n - 1;

    Dan

  • Lauren Roundy

    August 2, 2019 at 3:08 pm

    Thank you so much Dan! You truly are a true hero in the AE community.

    Would you be willing to break down exactly what the expression you gave me is doing or how it works? I understand the variables to a degree, but I wish I could wrap my head around how exactly it works. Either way, thanks so much!

  • Dan Ebberts

    August 2, 2019 at 3:59 pm

    The expression retrieves the index of the most recent, previous marker and subtracts 1 from that value. If there hasn’t been a marker yet, the result will be -1.

    Dan

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