Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Contributor ,
Feb 11, 2020 Feb 11, 2020

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.

TOPICS
Error or problem , Expressions , How to , Resources , Scripting
572
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Feb 12, 2020 Feb 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.

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 12, 2020 Feb 12, 2020
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines