Copy link to clipboard
Copied
Letssay I have a keyframe of text source layer changing every second for ten seconds, and the playhead is somewhere between five and six seconds. I want an expression to count all all previous keyframes, so it would return five in this case. Once we jump up to six seconds it returns six, counting all the previous source text key-frames. how would I do this?
Copy link to clipboard
Copied
Let's call your text layer with the keyframes on the Source Text: myText
Create a second empty text layer and put this expression on its Source Text:
if (thisComp.layer("myText").text.sourceText.nearestKey(time).time > time) {
thisComp.layer("myText").text.sourceText.nearestKey(time).index-1;
} else {
thisComp.layer("myText").text.sourceText.nearestKey(time).index;
}
Hope this helps.
And this thread should be moved to the Expressions Sub-forum
Find more inspiration, events, and resources on the new Adobe Community
Explore Now