Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to Animate a Slider with external Json file?

  • How to Animate a Slider with external Json file?

    Posted by John Westlen on February 9, 2019 at 7:05 pm

    Hello,

    So I am trying to make an array of numbers, 48 numbers to be exact. And would like After Effects to use that data written on a Json file and have it imported to a slider. Also, having the numbers change every four seconds.
    Example of what i mean:
    Array-
    [
    {
    “ID”: 1,
    “slider”: 1000,
    “duration”: 4
    },
    {
    “ID”: 2,
    “slider”:2000 ,
    “duration”: 4
    },

    so when the slider starts at 1,000 it animates and plays all the numbers between 1,000-2,000 within four seconds and then gets to 2,000.

    How could i go about doing this?

    I am new to coding so please if you are kind enough to explain this to me.

    Thank you!

    Oleg Pirogov replied 7 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Oleg Pirogov

    February 11, 2019 at 7:41 am

    My shot will be:

    $.evalFile('PUT_YOUR_JSON_FILE_PATH_HERE');

    var dur = 0;

    for (var i=0, len = arr.length; i

    [This goes to slider property expression]

    As I understand your data, IDs are points in time separated from each other by corresponding durations. So the expression sums consequent durations to find a pair of points in time a.k.a. IDs (namely ID i and ID i+1) between which the current time falls. Then it interpolates between slider values of those IDs, i.e. "plays all the numbers between 1,000-2,000 within four seconds and then gets to 2,000".

    If current time is beyond the last ID, slider freezes at the slider value of the last ID (arr[len-1].slider).

    The JSON file looks as follows:
    var arr = [{"ID": 1, "slider": 1000, "duration": 4}, {"ID": 2, "slider":2000, "duration": 4}, {"ID": 3, "slider": 3000, "duration": 4}];

    Seems to work as intended.

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