ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

expression needed to create random display of zeros and ones

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
paul colin
expression needed to create random display of zeros and ones
on Apr 9, 2014 at 5:06:59 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


Return to posts index

Dan Ebberts
Re: expression needed to create random display of zeros and ones
on Apr 9, 2014 at 5:28:27 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



Return to posts index

paul colin
Re: expression needed to create random display of zeros and ones
on Apr 9, 2014 at 5:46:54 pm

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



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]