Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

count keyframes to current time

Engaged ,
Jun 05, 2019 Jun 05, 2019

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?

318
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 05, 2019 Jun 05, 2019
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines