FORUMS: list search recent posts

# multiple variables expression

FAQ   •   VIEW ALL
 multiple variables expression on Aug 19, 2014 at 7:14:49 am

Hi,

I was wondering if it is possible to write an expression with multiple variables in it
I am fairly new with expressions so maybe I ask something completely impossible
For example: I have a slider, starting at frame 0 and it has a value of 10 and then at frame 25 the slider has a value of 120 and then at frame 50 the slider has a value of 35 etc..
I have this expression:

animationLength=1;
BB=['10','120','35'];
BB[Math.floor(time*animationLength) % BB.length]

Something like this is pretty o.k. but the problem is: the values needs to be counting up or down
And in this expression the values work like a hold key
So I tried a different approach; put 4 keyframes on the slider track and tried this expression
V1 = 10;
V2 = 120;
V3 = 35;
V4 = 85;

t1 = key(1).time;
t2 = key(2).time;
t3 = key(3).time;
t4 = key(4).time;

if (t1<=t2) linear(time,t1,t2,V1,V2)

else if (t2<=t3) linear(time,t2,t3,V2,V3)

else

(t3<=t4) linear(time,t3,t4,V3,V4)

I cannot get this to work
I am looking to find a solution for this
Does anyone has a solution for this, or have a different idea of how to get it working?

Thanks!

`0`

 Re: multiple variables expressionon Aug 19, 2014 at 4:10:05 pm

I think you were close:

``` if (numKeys > 3){ V1 = 10; V2 = 120; V3 = 35; V4 = 85; t1 = key(1).time; t2 = key(2).time; t3 = key(3).time; t4 = key(4).time; if (time < t2) linear(time,t1,t2,V1,V2) else if (time < t3) linear(time,t2,t3,V2,V3) else linear(time,t3,t4,V3,V4) }else value ```

Dan