Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random numbers in one source text

  • Random numbers in one source text

    Posted by Kyle Maven on October 30, 2019 at 4:39 pm

    I want to display a group of six numbers, each with a value of either 0 or 1 (with spaces between). I want each number to randomize every 4-8 frames. I was hoping to keep it all in one layer’s Source Text with the ability to add more numbers with a slider (instead of 6 numbers, I want 9 or 12). Also I want the seed to be different if I duplicate the layer.

    I don’t know too much about expressions but I know its a combination of posterizeTime, seedRandom, Math.round, gaussRandom, repeat, and a slider. But I just don’t know how to lay it all out.

    Right now I am just working on getting them all to be different numbers, then I was going to work on “adding” numbers but I’m stumped. The expression I currently have displays all the same number.

    0 0 0 0 0 0

    but I want something like
    1 0 0 1 1 0 >>> 1 0 1 1 0 0

    I appreciate any help!

    posterizeTime(gaussRandom(4,8);
    seedRandom(index, timeless = false);
    Num = Math.round(gaussRandom(0,1));

    Num + " " + Num + " " + Num + " " + Num + " " + Num + " " + Num + " "

    Kyle Maven replied 6 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 30, 2019 at 6:05 pm

    You need to call random() (or gaussRandom()) for each number, something like this:


    seedRandom(index, false);
    n = 6; //number of digits
    str = "";
    for (i = 0; i < n; i++){
    str += Math.round(gaussRandom(0,1)) + (i == n-1 ? "" : " ");
    }
    str

  • Kyle Maven

    October 30, 2019 at 8:37 pm

    Just added posterizeTime() but works perfectly! Thanks!

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