Answers.Body: <p>This will animate between the values in the array, hitting each value precisely at the second mark <em>though the viewer won't be able to notice because the numbers will be moving too fast</em>.</p>
  
  
  
  <pre><code>var dataArr = [7609,7758,7916,8063,8217,8382,8545,8701,8871,9049,9241,9386,9533,9722,9911,10055,10196,10321,10327,10451,10646,10854,11005,11195,11411,11583,11740,11904,12051,12177,12308,12404,12484,12558,12637,12725,12805,12882,12982,13088,13212,13340,13486,13674,13840]; 
  var sek = Math.floor(time);
  if (sek &lt; dataArr.length - 1){
     Math.floor(linear(time-sek, dataArr[sek], dataArr[sek+1]));
  } else {
      "out of data";
  }
  </code></pre>
  
  <p><strong>For bonus points</strong> you can add commas or culture-appropriate separators by replacing the line that starts with <code>Math.floor(linear …</code> with:</p>
  
  
  
  <pre><code>Math.floor(linear(time-sek, dataArr[sek], dataArr[sek+1])).toLocaleString("en-AU");
  </code></pre>
  
  <p>where you replace "en-AU" with your locale, e.g. for Chinese Decimal units use "zh-Hans-CN-u-nu-hanidec" and it will look like: 七,六〇九</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-09T01:42:42.663Z
Answers.LastActivityDate: 2020-04-09T01:42:42.663Z
Answers.UserDisplayName: stib
Body: <p>I'm trying to create a counter that automatically updates to the next value once per second.  I have that part figured out:</p>
  
  <pre><code>string = "7609,7758,7916,8063,8217,8382,8545,8701,8871,9049,9241,9386,9533,9722,9911,10055,10196,10321,10327,10451,10646,10854,11005,11195,11411,11583,11740,11904,12051,12177,12308,12404,12484,12558,12637,12725,12805,12882,12982,13088,13212,13340,13486,13674,13840,";
  array = string.split(",")
  l=array.length;
  
  sek = Math.floor(time);
  
  if(sek&lt;l){
              array[sek]; 
  }else{
              "End of Data";
  }
  </code></pre>
  
  <p>However, now I'm trying to animate it.  I've made simple counters that count from a starting number to a final number using Slider Control and keyframes, but is there a way to automate it?  The final project is going to have multiple counters going at the same time, with around 750 points of data in total, so automating would save so much time.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-08T14:00:38.007Z
Comments.Text: It's a little bit unclear what you're asking. When you say "is there a way to automate it", what exactly are you wanting to automate? BTW you could just do `array = [7609,7758,7916,8063,8217,8382, …` without making it into a string and then splitting it.
Comments.UserDisplayName: stib
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-08T18:35:04.017Z
Comments.Text: To clarify, what I have currently updates the count once per second. What I'd like it to do is to animate the numbers in between 7609 and 7758 and then between 7758 and 7916  rather than just going straight from 7609 to 7758. Rephrased: I'd like to see the integer values in between 7609 and 7758 like 7609 then 7610 then 7611, all the way up to 7758. What I've done in the past is link 2 numbers via the Slide Control and setting keyframes. This counts up like I want it to, however I have to manually set every single keyframe and type in the 2 numbers I want it to start and finish with.
Comments.UserDisplayName: izaic3
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-08T18:36:30.027Z
Comments.Text: With regards to the array, would this be what you mean?
  `array = [7609,7758,7916,8063,8217,8382,8545,8701,8871,9049,9241,9386,9533,9722,9911,10055,10196,10321,10327,10451,10646,10854,11005,11195,11411,11583,11740,11904,12051,12177,12308,12404,12484,12558,12637,12725,12805,12882,12982,13088,13212,13340,13486,13674,13840]
    
  l=array.length;
    
  sek = Math.floor(time);
    
  if(sek<l){  
              array[sek];   
  }else{  
              "End of Data";  
  }  
  `
Comments.UserDisplayName: izaic3
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-09T01:13:25.970Z
Comments.Text: When you get from 7609 to 7758, what happens then? Do you want it to continue to count until it gets to 13840? Maybe explain what you are trying to do, big picture.
Comments.UserDisplayName: stib
Tags: <after-effects><after-effects-expressions>
Title: Custom Animated Counter in Adobe After Effects
UserDisplayName: izaic3
ThreadText: # Custom Animated Counter in Adobe After Effects
  
  (Asked by: username_0 on 2020-04-07)
  
  I'm trying to create a counter that automatically updates to the next value once per second. I have that part figured out:
  
  ```
  string = "7609,7758,7916,8063,8217,8382,8545,8701,8871,9049,9241,9386,9533,9722,9911,10055,10196,10321,10327,10451,10646,10854,11005,11195,11411,11583,11740,11904,12051,12177,12308,12404,12484,12558,12637,12725,12805,12882,12982,13088,13212,13340,13486,13674,13840,";
  array = string.split(",")
  l=array.length;
  
  sek = Math.floor(time);
  
  if(sek<l){
              array[sek]; 
  }else{
              "End of Data";
  }
  
  ```
  
  However, now I'm trying to animate it. I've made simple counters that count from a starting number to a final number using Slider Control and keyframes, but is there a way to automate it? The final project is going to have multiple counters going at the same time, with around 750 points of data in total, so automating would save so much time.
  
  **Tags:** after-effects, after-effects-expressions
  
  > **Comments:**
  > **username_1**: It's a little bit unclear what you're asking. When you say "is there a way to automate it", what exactly are you wanting to automate? BTW you could just do `array = [7609,7758,7916,8063,8217,8382, …` without making it into a string and then splitting it.  
  > **username_0**: To clarify, what I have currently updates the count once per second. What I'd like it to do is to animate the numbers in between 7609 and 7758 and then between 7758 and 7916  rather than just going straight from 7609 to 7758. Rephrased: I'd like to see the integer values in between 7609 and 7758 like 7609 then 7610 then 7611, all the way up to 7758. What I've done in the past is link 2 numbers via the Slide Control and setting keyframes. This counts up like I want it to, however I have to manually set every single keyframe and type in the 2 numbers I want it to start and finish with.  
  > **username_0**: With regards to the array, would this be what you mean? `array = [7609,7758,7916,8063,8217,8382,8545,8701,8871,9049,9241,9386,9533,9722,9911,10055,10196,10321,10327,10451,10646,10854,11005,11195,11411,11583,11740,11904,12051,12177,12308,12404,12484,12558,12637,12725,12805,12882,12982,13088,13212,13340,13486,13674,13840]    l=array.length;    sek = Math.floor(time);    if(sek<l){               array[sek];    }else{               "End of Data";   }   `  
  > **username_1**: When you get from 7609 to 7758, what happens then? Do you want it to continue to count until it gets to 13840? Maybe explain what you are trying to do, big picture.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-04-09. Score: 1
  
  This will animate between the values in the array, hitting each value precisely at the second mark *though the viewer won't be able to notice because the numbers will be moving too fast*.
  
  ```
  var dataArr = [7609,7758,7916,8063,8217,8382,8545,8701,8871,9049,9241,9386,9533,9722,9911,10055,10196,10321,10327,10451,10646,10854,11005,11195,11411,11583,11740,11904,12051,12177,12308,12404,12484,12558,12637,12725,12805,12882,12982,13088,13212,13340,13486,13674,13840]; 
  var sek = Math.floor(time);
  if (sek < dataArr.length - 1){
     Math.floor(linear(time-sek, dataArr[sek], dataArr[sek+1]));
  } else {
      "out of data";
  }
  
  ```
  
  **For bonus points** you can add commas or culture-appropriate separators by replacing the line that starts with `Math.floor(linear …` with:
  
  ```
  Math.floor(linear(time-sek, dataArr[sek], dataArr[sek+1])).toLocaleString("en-AU");
  
  ```
  
  where you replace "en-AU" with your locale, e.g. for Chinese Decimal units use "zh-Hans-CN-u-nu-hanidec" and it will look like: 七,六〇九
  
  
  ---
  
  