Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Multi Numbers to 1 Sec Number

  • Multi Numbers to 1 Sec Number

    Posted by Stefan Novakovic on December 17, 2015 at 6:15 pm

    Hello, i am newbie and please understand me.
    I need expressions that will show numbers in text layer every second.
    For example i have this numbers “48 50 57 32 44” i want them to be showed in Text layer each every second like “at 1 second 48 number at 2 second 50 number at 3 second 32 number”

    I hope you will understand what i mean

    Stefan Novakovic replied 10 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Kalleheikki Kannisto

    December 17, 2015 at 9:27 pm

    Essentially you’ll need an array with your numbers

    my_array = [48, 50, 57, 32, 44];

    Then the source text for your test layer will need to pull out the number by time:

    my_index = Math.floor(time);

    Math.floor() makes it so that only complete seconds are used as index numbers, not partial. Now you can get the corresponding number from your array:

    my_number = my_array[my_index]

    This will work as long as your comp is not more seconds than you have items in the list.

    If you want the last number to stay on longer, you can fix the second line of code to

    my_index = Math.min(Math.floor(time),my_array.length-1);

    This takes the smaller of the two numbers, either the time in full seconds OR the number of items in the array. Thus the last number will stay on when time passes beyond the last item.

    So, all in all:

    my_array = [48, 50, 57, 32, 44];
    my_index = Math.min(Math.floor(time),my_array.length-1);
    my_number = my_array[my_index]

  • Stefan Novakovic

    December 17, 2015 at 10:20 pm

    Thank you very very very Much!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy