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

Iteration Counter

Contributor ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

Hi, i am trying to create an expression, that counts the number of iterations, a formula needs to reach a given value, and am wondering if this is even possible in AE, since i could not find anything like this online... I tried the following:

var t=1;

var i=0;

if (t<5) {t+1, i+1};

;

I would like i to return 4 in this case, but it always returns 0. Any Suggestions?

Thanks a lot,

TOPICS
Expressions

Views

688

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Dec 09, 2016 Dec 09, 2016

Expressions have no memory, so incrementing a variable for the next frame won't work. Depending on what you're trying to do, you can usually do the necessary calculations using time, the current comp time.

Dan

Votes

Translate

Translate
Community Expert ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

Expressions have no memory, so incrementing a variable for the next frame won't work. Depending on what you're trying to do, you can usually do the necessary calculations using time, the current comp time.

Dan

Votes

Translate

Translate

Report

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
Contributor ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

Thanks, dan, that was what i feared. Maybe i will get it to work using time... do you know by any chance, whats the smallest increment of time i can use? is it a Frame? or is it smaller? Thanks for your help...

Votes

Translate

Translate

Report

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
Community Expert ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

time represents seconds since the start of the comp. You can use any fractional value you want. The duration of a single frame is available with thisComp.frameDuration.

Dan

Votes

Translate

Translate

Report

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
Contributor ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

LATEST

Thanks again! I think i was sloppy, describing my initial problem, i just got it to work using the following code:

i=0;

t=1;

while(t < 5){

i++, t=t+2;

}

Have a nice evening:)

Votes

Translate

Translate

Report

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