-
Dan Ebberts Code, What am I doing wrong
Hello,
I see that Dan has a lot of knowledge on here, i found a code he wrote for my issue on How to import Json file to after effects and link it to slider. He wrote this code (i edited the /4 part ) :
data = footage(“example.json”).sourceData;
rampTime = 3;
done = false;
i = t = tPrev = 0;
while (t <= time){
tPrev = t;
t += rampTime + parseFloat(data[i].duration)/ .4;
i++;
if (i >= data.length){
done = true;
break;
}
}
if (done){
parseFloat(data[data.length-1].slider);
}else{
if ((time – tPrev) < parseFloat(data[i-1].duration)/ .4){
parseFloat(data[i-1].slider);
}else{
v1 = parseFloat(data[i-1].slider);
v2 = parseFloat(data[i].slider);
t1 = parseFloat(data[i-1].duration)/ .4;
t2 = t1 + rampTime;
linear(time-tPrev,t1,t2,v1,v2);
}
}What this does is change the value every four seconds, the only problem is that i would like the slider’s value to constantly be changing so for example if i want the value to be 1,000 and the start of the animation and have it show all the numbers leading up to 2,000. 2,000 being my next value at the four second mark. The only problem with this code is that it delays the values for about 1.5 seconds, so what i mean is at the start (0 seconds) it stays at 1,000 and doesn’t change until the 1.25 seconds mark and then it displays numbers counting to 2,000 at the four second mark but then delays and stays at 2,000 for 1.25 seconds then changes again.
How can prevent the code from delaying?
My array looks like this:
[
{
“ID”: 1,
“slider”: 1000,
“duration”: .4
},
{
“ID”: 2,
“slider”: 2000,
“duration”: .4
},
{
“ID”: 3,
“slider”: 3828.52,
“duration”: .4
}]
So to be clear my problem is there is a delay in the animation in the slider, it stays at 1,000 for about 1.25 seconds before it counts up to 2,000 which is at the four second mark.
Thank you!