Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions expression needed to create random display of zeros and ones

  • expression needed to create random display of zeros and ones

    Posted by Paul Colin on April 9, 2014 at 5:06 pm

    I need some help creating an expression that would randomly display text, zeros and ones only.
    In other words if I have the following text: 0100111 I need it to cycle through randomly to change the 1’s to to 0’s and the 0’s to 1’s. I had been using the “buzz words” text preset to do this. But it is much too cumbersome to type in several variations of the basic text again and again in the expressions box.
    Anybody have a notion of a simple expression to do this?
    Thanks in advance!
    Paul Colin

    Paul Colin replied 12 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    April 9, 2014 at 5:28 pm

    Try this source text expression:

    numDigits = 7;
    freq = 5; // changes per second

    seed = Math.floor((time-inPoint)*freq);
    seedRandom(seed,true);
    str = “”;
    for (i = 0; i < numDigits; i++) str += (random() < .5) ? “0” : “1”;
    str

    Dan

  • Paul Colin

    April 9, 2014 at 5:46 pm

    Thanks Dan!
    Will try as soon as I get back to my studio. At work now no access to AE.

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