Skip to main content
Participating Frequently
May 15, 2024
Answered

Triggering animation with layer markers

  • May 15, 2024
  • 2 replies
  • 1054 views

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

This topic has been closed for replies.
Correct answer Dan Ebberts

 


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;

2 replies

Dan Ebberts
Community Expert
May 15, 2024

What is it supposed to do?

chadinko1Author
Participating Frequently
May 15, 2024

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.

 

Dan Ebberts
Dan EbbertsCorrect answer
Community Expert
May 15, 2024

 


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;
Mylenium
Brainiac
May 15, 2024

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

chadinko1Author
Participating Frequently
May 15, 2024

I'm new to expression, Can you please help me to fix the code.

Thanks