Copy link to clipboard
Copied
Hi Everyone,
I need help with a simple task.
I have a text layer with 2 keyframes on its "Source text", I want to link those keyframes values to another text's "Source text" values.
So, in my timeline, there are 3 text layers.
The 3rd one is the one that must have those expressions. It has 2 keyframes on the "source text".
So, on the 1st keyframe, it should "become" the 1st layer text, and on the 2nd keyframe, it should become the 2nd layer text.
I attached a picture so you can see it visually.
There's probably a more elegant way, but this should work:
if (time < key(2).time)
thisComp.layer("1st text").text.sourceText
else if (time < key(3).time)
thisComp.layer("2nd text").text.sourceText
else if (time < key(4).time)
thisComp.layer("3rd text").text.sourceText
else if (time < key(5).time)
thisComp.layer("4th text").text.sourceText
else if (time < key(6).time)
thisComp.layer("5th text").text.sourceText
else
thisComp.layer("6th text").text.sourceText
This is probably better:
layerNames = ["1st text","2nd text","3rd text","4th text","5th text","6th text"];
n = nearestKey(time).index;
if (time < key(n).time) n--;
if (n > 0) n--;
n = Math.min(n,layerNames.length-1);
thisComp.layer(layerNames[n]).text.sourceText
Copy link to clipboard
Copied
thisComp.layer("Reference").text.sourceText.valueAtTime(key(1).time)
Mylenium
Copy link to clipboard
Copied
Thanks for the help, but it didn't work.
It needs 2 expressions, one for the 1st keyframe, and another one for the 2nd keyframe.
I tried to use your script changing for the 2nd one also, but it didn't work.
It works only for one keyframe.
Please, look at my attached picture, it shows what I want to do.
Copy link to clipboard
Copied
You could do it like this:
if (time < key(2).time)
thisComp.layer("1st text").text.sourceText
else
thisComp.layer("2nd text").text.sourceText
Copy link to clipboard
Copied
Thanks a lot, Dan. you really helped me.
But I actually need this for ~6 texts and keyframes.
I tried this method for 3 texts and keyframes, and it didn't work.
could you help me again?
Copy link to clipboard
Copied
There's probably a more elegant way, but this should work:
if (time < key(2).time)
thisComp.layer("1st text").text.sourceText
else if (time < key(3).time)
thisComp.layer("2nd text").text.sourceText
else if (time < key(4).time)
thisComp.layer("3rd text").text.sourceText
else if (time < key(5).time)
thisComp.layer("4th text").text.sourceText
else if (time < key(6).time)
thisComp.layer("5th text").text.sourceText
else
thisComp.layer("6th text").text.sourceText
Copy link to clipboard
Copied
This is probably better:
layerNames = ["1st text","2nd text","3rd text","4th text","5th text","6th text"];
n = nearestKey(time).index;
if (time < key(n).time) n--;
if (n > 0) n--;
n = Math.min(n,layerNames.length-1);
thisComp.layer(layerNames[n]).text.sourceText
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more