Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Simple text expression

  • Simple text expression

    Posted by Lars Koerkemeier on February 18, 2009 at 7:30 pm

    Hi Everyone!
    I have two questions. My first question is that i have a list of like 5 words and i need an expression that will turn that into a list of about like 100 words placing those 5 words randomly with a space in between each word. I have done this with producing random numbers but i cant seem to be able to do it with a list of words.
    EX:
    Words: Hi, Bye, Dog, Cat, House
    What i want: Hi Dog Bye House Cat Bye Dog Cat Hi etc…

    My Second Question was that im trying to make a lot of text and numbers with a lot of rows and then put a track matte above it with a single word. the way i have it set up right now is with over 100 text layers using different expressions to create the text randomly. What i want to do is make maybe 8 expressions that each create a row of text and then make it place those rows randomly to make a total of 100 or so rows.
    How could i do this.
    Im going for a look kind of like this ESPN opening scene:
    https://www.trapcode.com/gallery/ESPNews_Montage_h.mov
    If you dont understand please ask
    Thanks
    -Lars

    Lars Koerkemeier replied 17 years, 7 months ago 2 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    February 18, 2009 at 9:03 pm

    This should work for your first question:

    words = [“Hi”,”Bye”,”Dog”,”Cat”,”House”];
    seedRandom(index,true);
    idx = Math.floor(random(words.length));
    str = “”;
    for (i = 1; i <= 100; i++){ str += words[idx] + " "; idx = (idx + Math.floor(random(words.length-1)) + 1)%words.length; } str Dan

  • Lars Koerkemeier

    February 18, 2009 at 10:33 pm

    Hey Dan,
    Thats exactly what I wanted! Now the only thing i need to do is pretty much make the expression you made plus a couple of the ones i already had and make on expression that takes those display in rows for about 100 rows randomly.
    EX:
    Hi Bye Dog Cat House Bye Cat Hi Dog House etc..
    125 332 221 548 456 684 489 655 156 221 118 etc…
    546 784 125 432 156 585 477 513 456 546 987 etc…
    Bye Dog Hi House Cat Dog House Bye Hi etc…

    Is there a way to give like just part of an expression a name so for example:

    A=
    words = [“Hi”,”Bye”,”Dog”,”Cat”,”House”];
    seedRandom(index,true);
    idx = Math.floor(random(words.length));
    str = “”;
    for (i = 1; i <= 100; i++){ str += words[idx] + " "; idx = (idx + Math.floor(random(words.length-1)) + 1)%words.length; } str B= list = 10; seedRandom(index, 1) stat = ""; for (i=0; i

  • Dan Ebberts

    February 19, 2009 at 12:05 am

    Well, you could call the random strings anything you want, but using the names already in your two expressions, you could just add a piece like this (not tested):

    s = “”;
    for (i = 1; 1 <= 100; i++){ if (random() < .5){ s += str; }else{ s += stat; } s += "\r"; } s Dan

  • Lars Koerkemeier

    February 19, 2009 at 12:38 am

    Hey Dan,
    Im getting an Error “Timeout while waiting for the engine” which if im right means its an infinate loop This is my current code:

    words = [“Hi”,”Bye”,”Dog”,”Cat”,”House”];
    seedRandom(index,true);
    idx = Math.floor(random(words.length));
    str = “”;
    for (i = 1; i <= 10; i++){ str += words[idx] + " "; idx = (idx + Math.floor(random(words.length-1)) + 1)%words.length; } str seedRandom(index, 1) stat = ""; for (i=0; i<10; i++){ r = (Math.floor(random(0, 100)*10)) + " "; stat = "YDS " + r + stat + " "; } s = ""; for (i = 1; 1 <= 2; i++){ if (random() < .5){ <-------Error s += str; }else{ s += stat; } s += "r"; } The error is on line 20 Thanks again for helping out -Lars

  • Dan Ebberts

    February 19, 2009 at 12:56 am

    This seems to work:

    words = [“Hi”,”Bye”,”Dog”,”Cat”,”House”];
    seedRandom(index,true);
    idx = Math.floor(random(words.length));
    str = “”;
    for (i = 1; i <= 10; i++){ str += words[idx] + " "; idx = (idx + Math.floor(random(words.length-1)) + 1)%words.length; } stat = ""; for (i=0; i<10; i++){ r = (Math.floor(random(0, 100)*10)) + " "; stat = "YDS " + r + stat + " "; } s = ""; for (i = 1; i <= 100; i++){ if (random() < .5){ s += str; }else{ s += stat; } s += "\\r"; } s In case it doesn't make it through, the r in quotes in the 3rd line from the bottom should be a backslash character then an r. Dan

  • Lars Koerkemeier

    February 19, 2009 at 1:04 am

    Hey Dan,
    That works great! Thank you so much
    -Lars

  • Lars Koerkemeier

    February 19, 2009 at 1:43 am

    Hey Dan
    Quick question. How would I go about adding more expressions to the final expression so instead of only using only 2 I can use like 8 different ones
    Thanks again
    -Lars

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