Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Combining 2 expressions on a slider control

  • Combining 2 expressions on a slider control

    Posted by Buki Bodunrin on January 18, 2016 at 6:12 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 (https://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)

    Buki Bodunrin replied 10 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Miguel De mendoza

    January 18, 2016 at 3:31 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;

  • Buki Bodunrin

    January 18, 2016 at 6:41 pm

    Ah…

    It worked changing

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

    Thanks again!!!

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