Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Slider control keyframe value from JSON

  • Slider control keyframe value from JSON

  • Midleton Dequ

    May 24, 2022 at 2:30 pm

    So I’ve got this comp with a rectangle where width is controlled by a slider, so it always starts at 0 for the first key frame and ends at 200 for the last one, which lasts 1 second.

     

    How can I make it obtain the value from the json instead of manually adjusting the last keyframe value of the slider, which is 200? So for example if the pulled data is 100 then animate from 0 to 100 e.t.c.

     

    I usually use JSON data to change source text but not sure how can I use as a keyframe value like for this instance.

  • Dan Ebberts

    May 24, 2022 at 3:26 pm

    It’s a little complicated because an expression can’t just replace the value at a keyframe, it needs to replace every value. The simplest change would be construct your own linear ramp, using the slider keyframes to provide the timing info and the first value and your data file to provide the second value. That could look like this (not tested, so there may be typos):

    val = footage("value.json").dataValue([0]);

    rect = thisComp.layer("Null 1").effect("Slider Control")("Slider");

    linear (time,rect.key(1).time, rect.key(2).time, rect.key(1).value, val);

    But it seems like you could clean this up and get rid of the slider altogether, but you’d have to get the timing info from somewhere else (or hard code it).

  • Midleton Dequ

    May 24, 2022 at 4:20 pm

    Thanks, this works… I altered a little bit so it animated only the width not height and made use of ease.

    val = footage("value.json").dataValue([0])
    rect = thisComp.layer("Null 1").effect("Slider Control")("Slider");
    [ease(time,rect.key(1).time, rect.key(2).time, rect.key(1).value, val),20]

    Can you show the alternative way you said of getting rid of the slider?

  • Dan Ebberts

    May 24, 2022 at 4:35 pm

    One thing you could do is put the keyframes directly on the shape size. Then you could do something like this (again, not tested):

    val = footage("value.json").dataValue([0])

    [ease(time, key(1).time, key(2).time, key(1).value[0], val),20]

Viewing 1 - 4 of 4 posts

Log in to reply.

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