FORUMS: list search recent posts

# Combining 2 expressions on a slider control

FAQ   •   VIEW ALL
 Combining 2 expressions on a slider control on Jan 18, 2016 at 6:12:23 am

Hi I'm having trouble getting 2 expression to work together on a slider control. Thanks to the wonderful Dan Ebberts, I'm using this expression to randomize a bunch of stills in a composition (http://motionscript.com/expressions-lab-ae65/random-stills.html). My trouble is whenever the slider hits a value on 1, no stills are shown. I'd like to add to the expression so that the minimum value never goes below 2. Dan's expression looks like this:

```duration = .125; //length of each cut (seconds) seed = Math.floor(time/duration) + 1; seedRandom(seed,true); Math.floor(random(1,index));```

I tried adding this line of code after:

`clamp(value, min=2, max=255)`

But it doesn't work. What am I doing wrong? Or is there a better way to do this?
Thanks!

```duration = .125; //length of each cut (seconds) seed = Math.floor(time/duration) + 1; seedRandom(seed,true); Math.floor(random(1,index)); clamp(value, min=2, max=255) ```

 Re: Combining 2 expressions on a slider controlon Jan 18, 2016 at 3:31:26 pm

You can change the random() min parameter to 2 like this:
`Math.floor(random(2,index));`

Or you can check the value with an if statement:
```duration = .125; //length of each cut (seconds) seed = Math.floor(time/duration) + 1; seedRandom(seed,true); randomValue = Math.floor(random(1,index)); val = (randomValue < 2) 2: randomValue;```

 Re: Combining 2 expressions on a slider controlon Jan 18, 2016 at 6:41:08 pm

Ah...

It worked changing

`Math.floor(random(2,index));`

Thanks again!!!