Skip to main content
Adirai Maji
Inspiring
February 12, 2020
Question

How to make time varying for loop expression that changes value for every sec..

  • February 12, 2020
  • 2 replies
  • 660 views

example. I've made this expression inside Source Text Property.

for (t = Math.round(time); t<10 ; t++){
	t
	}

 

When I click away. This loop runs through and shows only last value that is 9. But all I want is limit this loop based on time. So if I change this expression to

 

for (t = Math.round(time); t<10 ; time){
	t
	}

 

After effects goes unresponding. So how can I use these type of loops in after effects.

This topic has been closed for replies.

2 replies

Mylenium
Legend
February 12, 2020

Loops can also be controlled with break and continue. But Martin is right - your syntax makes very little or no sense to begin with. You've just writtne a bit of useless code that will always return the last value in the loop, no matter what condition.

 

Mylenium

Martin_Ritter
Legend
February 12, 2020

In AE, a for-loop iterates on the current frame, until it's condition isn't true anmore. Both of your examples are a wrong use of for.

 

Usual, for a for-loop you have a new iterate-variable and if you want to control the loop over time, you switch it on and off with an if-condition.

 

if (Math.floor(time) < 10){

    for (i = 0; i < 5; i ++){

        ... some code ...

    };

};

 

For a better help, please tell as in more detail, what you want to achive.