ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Remapping array to slider with easing

FAQ   •   VIEW ALL
 Remapping array to slider with easing on Jan 22, 2019 at 3:48:47 pm

Hi all

I have what I thought was simple that really has me stumped!

I've an array of y positions that I'd like to simply remap to a slider so the array[0] is 0 on a slider, array[1] is 1 on a slider, array[2] is 2 on slider..... so I can animate between positions with simple values on a slider.

I think there's some loop to do that I can't figure out, any help would be much appreciate!

 Re: Remapping array to slider with easingon Jan 22, 2019 at 5:11:21 pm

It might be like this (unless you need tweening, which would be a little more complicated):

s = effect("Slider Control")("Slider");
yPos = [100,200,300,400,500];
idx = Math.round(clamp(s,0,yPos.length-1));
y = yPos[idx];
[value[0],y]

Dan

 Re: Remapping array to slider with easingon Jan 22, 2019 at 6:00:24 pm

Many thanks Dan.

Apologies - I inadvertently pressed the Report Post button!!!

That's great, but yes - really want tweening. I'll go the long way round for now as it sounds quite complicated. Many thanks for your time.

 Re: Remapping array to slider with easingon Jan 22, 2019 at 6:08:32 pm

There are a number of ways to do it, but this should work:

s = effect("Slider Control")("Slider");
yPos = [100,200,300,400,500];
idx = clamp(s,0,yPos.length-1);
idx1 = Math.floor(idx);
idx2 = Math.ceil(idx);
y1 = yPos[idx1];
y2 = yPos[idx2];
y = ease(idx,idx1,idx2,y1,y2);
[value[0],y]

Dan