ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Lauren Roundy
I want a text layer to change based on my marker index
on Aug 1, 2019 at 11:09:55 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!


Return to posts index

Lauren Roundy
Re: I want a text layer to change based on my marker index
on Aug 1, 2019 at 11:13:51 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


Return to posts index

Dan Ebberts
Re: I want a text layer to change based on my marker index
on Aug 2, 2019 at 12:21:03 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



Return to posts index


Lauren Roundy
Re: I want a text layer to change based on my marker index
on Aug 2, 2019 at 3:08:12 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!


Return to posts index

Dan Ebberts
Re: I want a text layer to change based on my marker index
on Aug 2, 2019 at 3:59:44 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



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]