Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions: Alternating between 2 values

  • Expressions: Alternating between 2 values

    Posted by Ryan Paterson on August 4, 2009 at 6:59 pm

    Hey y’all. So I have this lightning bolt, and I need it to go from 100% opacity to 0% opacity to create flickering. What is a good expression to alternate between these values?? I’m using a random expression so that I can control the timing of it, so I just need a way to clamp the values to 0 and 100.

    Also, I’m using seedRandom to make it switch values every second:

    seedRandom(Math.floor(time), true);

    But how do I get it on the half second?

    This is basic stuff I know but I can never remember expressions…

    Robert Paynter replied 16 years, 9 months ago 2 Members · 1 Reply
  • 1 Reply
  • Robert Paynter

    August 4, 2009 at 10:17 pm

    Here is an old expression from Dan Ebberts

    minOnTime = .5;
    maxOnTime = 2.0;
    minOffTime = .5;
    maxOffTime = 1.5;

    i = 0;
    tEnd = 0;
    seedRandom(index,true);

    preRun = random(maxOnTime);
    while (time + preRun >= tEnd){
    i++;
    if(i%2){
    tEnd += random(minOnTime,maxOnTime);
    result = 100;
    }else{
    tEnd += random(minOffTime,maxOffTime);
    result = 0;
    }
    }
    result

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