Copy link to clipboard
Copied
Hi Everyone,
I need help to refine this expression of triggering animation with layer markers.
I have animation of a text that starts with key 1 to key 2 and then this text transition to another text key 3 to key 4 and then text out key 5 to key 6.
The 2 texts layers are pre composed, and my expression is applied into the Time remapping with these 6 keys.
Basecaly, the expression works fine, just I'm getting expression error for this line
if (time < T.marker.key(1).time)
linear(time,inPoint.time,key(2).time,key(1).value,key(2).value)
else
Everytime, I move my timeline indecator before my marker.key(1). But the expression keeps working fine.
This is my expression:
T = thisLayer;
if ((T.marker.numKeys > 1 ) && (numKeys > 5)){
dIn = key(4).time - key(3).time;
dTr = key(2).time - key(1).time;
dOut = key(6).time - key(5).time;
eIn = T.marker.key(1).time;
eOut = T.marker.key(2).time;
if (time < T.marker.key(1).time)
linear(time,inPoint.time,key(2).time,key(1).value,key(2).value)
else
value
if (time < T.marker.key(2).time)
linear(time,eIn,eIn+dIn,key(3).value,key(4).value)
else
linear(time,eOut,eOut+dOut,key(5).value,key(6).value);
}else
value;
Thank you for your help
In that case, I think it would be like this:
if ((marker.numKeys > 1 ) && (numKeys > 5)){
dIn = key(2).time - key(1).time;
dTr = key(4).time - key(3).time;
dOut = key(6).time - key(5).time;
eIn = marker.key(1).time;
eOut = marker.key(2).time;
if (time < eIn)
linear(time,inPoint,inPoint+dIn,key(1).value,key(2).value)
else if (time < eOut)
linear(time,eIn,eIn+dTr,key(3).value,key(4).value)
else
linear(time,eOut,eOut+dOut,key(5).value,key(6).value);
}else
value;
Copy link to clipboard
Copied
Your branching in the conditional is wrong. The precedence is
if
else if
else
Also your code is sloppy. Even else statements require ( ). Fix your syntax and formatting and it should work correctly.
Mylenium
Copy link to clipboard
Copied
I'm new to expression, Can you please help me to fix the code.
Thanks
Copy link to clipboard
Copied
What is it supposed to do?
Copy link to clipboard
Copied
I have 3 animations In, transion and Out
The In can be always at the bigenning of the layer, first marker should trigger the transition and then the second marker should trigger the Out.
Copy link to clipboard
Copied
In your code, it looks like the transition happens before the In, is that correct?
Copy link to clipboard
Copied
The In animation can always starts at the inPoint of my layer (it doesn't need a trigger). transition should be triggered by marker.key(1) and then Out should be triggered by marker.key(2)
Copy link to clipboard
Copied
Copy link to clipboard
Copied
In that case, I think it would be like this:
if ((marker.numKeys > 1 ) && (numKeys > 5)){
dIn = key(2).time - key(1).time;
dTr = key(4).time - key(3).time;
dOut = key(6).time - key(5).time;
eIn = marker.key(1).time;
eOut = marker.key(2).time;
if (time < eIn)
linear(time,inPoint,inPoint+dIn,key(1).value,key(2).value)
else if (time < eOut)
linear(time,eIn,eIn+dTr,key(3).value,key(4).value)
else
linear(time,eOut,eOut+dOut,key(5).value,key(6).value);
}else
value;
Copy link to clipboard
Copied
Working perfectly.
Thank you very much for your help, much appreciate it.