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

[For Expression Genius] How can I write expression that have incremental variable with if condition?

Contributor ,
Mar 09, 2020 Mar 09, 2020

I want to write an expression in after effects which allows to have incremental number variable...

 

This is what I wanna do, Let me explain my need.

 

I've applied a slider to a text layer. And I wrote the following expression to sourceText property of the text layer

 

i = 0;
slider = Math.round(effect("Slider Control")("Slider"));
if (!(slider/4 % 1)){
	i++;
	}else{
slider+i;
	}

 

 

I want to know how can I make that i++ affect i value in the first line. If the slider value is divisible by 4 which are 4,8,12,16 and so on.. the i should Increase it's value from 0 to 1. Means when the slider cross the value 4 the value of  i should change to 1 So when the slider value is 5 now the print value will be slider+i which is (5+1) six 6. and when the slider cross the value 8. the value of i should be 2. and this should happens inside the expression. I know I've assigned i=0; so this expression won't work. I want to achieve the thing I've asked. How can I write the expression to achieve it?????

TOPICS
Dynamic link , Expressions , How to , Resources
1.4K
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

correct answers 1 Correct answer

Community Expert , Mar 09, 2020 Mar 09, 2020

Wouldn't this work?

 

slider = Math.round(effect("Slider Control")("Slider"));
i = Math.floor(slider/4);
slider+i

 

Dan

Translate
LEGEND ,
Mar 09, 2020 Mar 09, 2020

A simple for() loop will do.

 

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
Contributor ,
Mar 09, 2020 Mar 09, 2020

No. In expression editor for() loop only returns the value from last loop. I won't care about other values.

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
Community Expert ,
Mar 09, 2020 Mar 09, 2020

Wouldn't this work?

 

slider = Math.round(effect("Slider Control")("Slider"));
i = Math.floor(slider/4);
slider+i

 

Dan

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
Contributor ,
Mar 09, 2020 Mar 09, 2020
LATEST

It worked... Thanks.

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