ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression count up values in specific time

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Hung NguyenDac
Expression count up values in specific time
on Apr 19, 2020 at 2:23:20 am
Last Edited By Hung NguyenDac on Apr 19, 2020 at 2:40:42 am

Hello everyone. I'm trying this expression. But the problem is when i key Slider from 50->51->52. The value in source text change in a single frame. Is it possible to make the value count up in 1 second instead of 1 frame?
x=Math.round(comp("MainComp").layer("Value Control").effect("Value 1")("Slider"));
if(x==50) footage("Values.csv").dataValue([2,0]) else
if(x==51) footage("Values.csv").dataValue([2,1]) else
if(x==52) footage("Values.csv").dataValue([2,2]) else
if(x==53) footage("Values.csv").dataValue([2,3]) else
if(x==54) footage("Values.csv").dataValue([2,4]) else
if(x==55) footage("Values.csv").dataValue([2,5]) else
value

TIA ☺


Return to posts index

Dan Ebberts
Re: Expression count up values in specific time
on Apr 19, 2020 at 4:41:17 am

The key to making something like this work is that your expression has to be able to figure out when the slider changed to a particular value. Do you have a keyframe for each slider value? If so, it's fairly straighforward. If not, it's more cumbersome, but it can still be done. So how are you driving the slider values, exactly?

Dan



Return to posts index

Hung NguyenDac
Re: Expression count up values in specific time
on Apr 19, 2020 at 5:02:15 am

Hi Dan.
Yes. I have 1 Slider and about 30 Toggle Hold Keyframe on it.
Each keyframe will get the value from csv file to Source Text.
Currently, when I key Silder's value from 50->51. The source text will change (500->1000) Immediately in 1 frame when the Slider's value = 51.
I'm looking for is it possible to make it change (500 count up to 1000) In 30 frames (1s) After each new keyframe of slider?


Return to posts index


Dan Ebberts
Re: Expression count up values in specific time
on Apr 19, 2020 at 6:20:17 am

It seems like the value of the slider doesn't matter, just the index of the most recent keyframe. It will probably looks something like this:


s = comp("MainComp").layer("Value Control").effect("Value 1")("Slider");
v = value;
if (s.numKeys > 0){
n = s.nearestKey(time).index;
if (time < s.key(n).time) n--;
if (n > 0){
if (n ==1){
v = footage("Values.csv").dataValue([2,0]);
}else{
t = time - s.key(n).time;
v1 = footage("Values.csv").dataValue([2,n-2]);
v2 = footage("Values.csv").dataValue([2,n-1]);
v = linear(t,0,1,v1,v2);
}
}
}
v



Dan



Return to posts index

Hung NguyenDac
Re: Expression count up values in specific time
on Apr 19, 2020 at 9:26:28 am

Thanks a lot for your help Dan. I tried it and seem like expressions can not execute what i'm thinking, i'll continue with old expression. Hope you are staying safe in the pandemic 😉


Return to posts index

Hung NguyenDac
Re: Expression count up values in specific time
on Apr 23, 2020 at 10:14:50 am

Hi Dan. I'm facing a problem.
Text 1. Source Text: It's simple and working fine.
x=thisComp.layer("Null 1").effect("Slider")("1");
if (x==1) "Name 1" else if(x==2) "Name 2" else "Name 3"


Text 2 . Source Text: The problem in line 3.
<b>n=Math.round(thisComp.layer("Text 1").text.sourceText)+".csv"</b>;
x=Math.round(comp("MainComp").layer("Null 2").effect("Slider")("Slider"));
<b>if(x==50) footage<b>(n)</b>.dataValue([2,0]) else value</b>


When i key Null 1 change from "Name 1" -> "Name 2". But Text 2 can't get "Name 2.csv" to n, After Effects shows error couldn't find footage named NaN.csv.
I'm trying to add "" to n by this if(x==50) footage<b>((")+n+("))</b>.dataValue([2,0]) else value. it's wrong.
Is there any way to make it work?


Return to posts index


Hung NguyenDac
Re: Expression count up values in specific time
on Apr 23, 2020 at 10:18:08 am

Hi Dan. I'm facing a problem.
Text 1. Source Text: It's simple and working fine.
x=thisComp.layer("Null 1").effect("Slider")("1");
if (x==1) "Name 1" else if(x==2) "Name 2" else "Name 3"


Text 2 . Source Text: The problem in line 3.
n=Math.round(thisComp.layer("Text 1").text.sourceText)+".csv";
x=Math.round(comp("MainComp").layer("Null 2").effect("Slider")("Slider"));
if(x==50) footage(n).dataValue([2,0]) else value


When i key Null 1 change from "Name 1" -> "Name 2". But Text 2 can't get "Name 2.csv" to n, After Effects shows error couldn't find footage named NaN.csv.
I'm trying to add "" to n by this
if(x==50) footage((")+n+(")).dataValue([2,0]) else value . it's wrong.
Is there any way to make it work?


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]