Skip to main content
Participating Frequently
August 4, 2021
Question

Problem using two expressions for controlling text.

  • August 4, 2021
  • 2 replies
  • 206 views

I found two great expressions on the web, one for random words (based on words in the layer name), and another for random fonts (from a font list in the expression.) They both work great on their own, but when I stack them together only the lower one works. I know this is a common problem but I can't figure it out. I see other posts with solutions to similar non-text scripts, but I can't figure how to apply those solutions to this. Thank you for any assistance you can give. I would love to be able to apply both of these to on text layer!
Here're the scripts (there's a frame rate slider associated with the random word script, but I'm not sure how to include that:
//random words

words=thisLayer.name.split(" ");

wordCount=words.length;

frameRate=effect("Frame Rate")("Slider");

seedRandom(Math.floor(time*frameRate), timeless = true)

randomNumber=random(0,wordCount);

roundedNumber=Math.floor(randomNumber);

words[roundedNumber]

 

// random fonts

var array = [ "Courier-Bold", "Copperplate-Bold", "Compacta-Normal", "Citore", "Cochin", "Izzard", ];

hold=0.2;

seed=Math.round(random(time/hold));

seedRandom(seed,true);

r=Math.round(random(53));

style.setFont(array[r])

words=thisLayer.name.split(" ");

wordCount=words.length; frameRate=effect("Frame Rate")("Slider");

seedRandom(Math.floor(time*frameRate), timeless = true)

randomNumber=random(0,wordCount);

roundedNumber=Math.floor(randomNumber);

words[roundedNumber]

This topic has been closed for replies.

2 replies

Mylenium
Legend
August 5, 2021

Perhaps an issue with parsing the font names? Have you tried to debug it by inserting a font name directly into the setStyle()?

 

Mylenium

Mylenium
Legend
August 5, 2021

The expressions need to be used on different layers with one feeding in the random words into the other's source text.

 

Mylenium

Participating Frequently
August 5, 2021

Thank you! I will try that.