-
Control more than two keyframes with expressions
Hello! I’ve been using this forum for a while now and it’s been always very helpful. I just came up with an idea that I’m not sure it’s possible, but I would like to share it in case someone can help me think of a different approach to it, if not guide me on the right path.
So right now I have a shape layer that has its wide controlled by an expression that compares the length of 3 different text layers and picks the widest one. Additionally to this, I have a 4th text layer that appears for 10 seconds which when it appears I have 4 keyframes to change the length of the shape layer.
The idea is to have keyframes 1 & 4 be the same, and have the 2nd and 3rd be also the same so 1 transition to 2, and 3 to 4.
Right now I’ve managed to write it so it either transitions well from one keyframe to the other with a linear expression. But I’d still need to do the second transition.
The following is the expression I’ve worked with, in bold you’d see I have two linear expressions but I can only have one happen as far as I know. (I think I probably just miss some javascript knowledge to make it happen).
dropMenu = comp(“WORD BANK”).layer(“ROMANIZATION”).effect(“Feature”)(“Menu”);
text1A = thisComp.layer(“Dialogue1_target_”).sourceRectAtTime().width;
text1B= thisComp.layer(“Dialogue1_target_RTL”).sourceRectAtTime().width;
text2 = thisComp.layer(“English”).sourceRectAtTime().width;
text3 = thisComp.layer(“Romanization 1”).sourceRectAtTime().width;
text4 = thisComp.layer(“Literal Translation1”).sourceRectAtTime().width;
widestA = Math.max(text1A, text2, text3);
widestB = Math.max(textB, text2, text3);
widestVar = Math.max(text1A, text2, text3, text4);
RLPadding = 130;
x = value[0];
y = value[1];
if (dropMenu == 1) {
if (engWide < engLitWide){
(linear(time,key(1).time,key(2).time,[x – widestA – RLPadding, y],[x – widestEng – RLPadding, y] && linear(time,key(3).time,key(4).time,[x – widestEng – RLPadding, y],[x – widestA – RLPadding, y]))
else
[x- widestA – RLPadding, y];
}
} else if (dropMenu == 2) {
[value[0]- widestA – RLPadding, value[1]];
} else if (dropMenu == 3) {
[value[0]- widestB – RLPadding, value[1]];
}
The idea would be to do the same in the other else if statements if this is doable.
Thank you in advance!
Best,
Anna