Skip to main content
Participant
November 10, 2014
Answered

Expression stops after if...else...statement

  • November 10, 2014
  • 2 replies
  • 624 views

Hi,

I am new to expressions and am trying to teach myself from the internet and books.  I have set myself a challenge to emulate a horizontal "ticker" line starting from right to left across the screen. When the text reaches a preset position (x=-3200), I want the layer to return to the right hand side and resume moving right to left for as long as the composition time. This is part of a larger project where several layers will follow on in continuous loops in the same manner as seen on TV. I have a simplified expression which I am trying out but as soon as the if statement is triggered the calculations stop and the layer stays at the x=1920 position. I cannot find a way to keep the action running. Am I missing something as I thought the expression was calculated at each frame ?

the expression:

x=position[0];

y=position[1];

x=position[0]+((time-inPoint)*-200);

if (x<-3200) x=1920;

[x,y]

I would be grateful for any help or advice.

Regards

John

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

I think I'd do something like this:

x = 1920 - ((time-inPoint)*200)%5120;

[x,value[1]]

Dan

2 replies

Participant
November 11, 2014

Thanks very much Dan. A much simpler solution. If you have the time could you please explain how the modulus 5120 causes the text to loop continuously.

Regards

John

Dan Ebberts
Community Expert
Community Expert
November 11, 2014

The modulus operator just gives the remainder of the division. For example,  time%10  will loop continuously, ramping from 0 to 10.

Dan

Participant
November 12, 2014

Thanks very much Dan.

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
November 10, 2014

I think I'd do something like this:

x = 1920 - ((time-inPoint)*200)%5120;

[x,value[1]]

Dan