Hello, this may be an embarrassingly easy fix, but I'm a newbie. I'm trying to assign individual characters in a large text range a random selection out of an array of colors and can't get the thing to work.
Here's what I have:
var colorArray = new Array();
var sel = activeDocument.selectedItems;
colorArray[0] = new CMYKColor(0,15,41,15);
colorArray[1] = new CMYKColor(23.15,75.7,55.3,6.3);
colorArray[2] = new CMYKColor(0,11,20,20);
colorArray[3] = new CMYKColor(34.5,47.85,53.7,6.7);
colorArray[4] = new CMYKColor(8.25,20.8,37.65,0);
//assuming selected item is a text range
for(i=1; i<sel.length; i++){
sel.characters[i].setColor(colorArray[Math.round(Math.random()*(4-1))+1]);
}
I've made one work by appending a js script to the scripts menu in CS2 but it's very very slow (quite a few hours sometimes days slow). In case it helps though, here is the working script not used through scriptographer:
var colorArray = new Array();
colorArray[0] = new CMYKColor();
colorArray[0].cyan = 0;
colorArray[0].magenta = 15;
colorArray[0].yellow = 41;
colorArray[0].black = 15;
colorArray[1] = new CMYKColor();
colorArray[1].cyan = 23.15;
colorArray[1].magenta = 75.7;
colorArray[1].yellow = 55.3;
colorArray[1].black = 6.3;
colorArray[2] = new CMYKColor();
colorArray[2].cyan = 0;
colorArray[2].magenta = 11;
colorArray[2].yellow = 20;
colorArray[2].black = 20;
colorArray[3] = new CMYKColor();
colorArray[3].cyan = 34.5;
colorArray[3].magenta = 47.85;
colorArray[3].yellow = 53.7;
colorArray[3].black = 6.7;
colorArray[4] = new CMYKColor();
colorArray[4].cyan = 8.25;
colorArray[4].magenta = 20.8;
colorArray[4].yellow = 37.65;
colorArray[4].black = 0;
for(i=0; i<activeDocument.textFrames[0].contents.length; i++){
activeDocument.textFrames[0].textRange.characters[i].characterAttributes.fillColor = colorArray[Math.round(Math.random()*(4-1))+1];
}
I would be super grateful for any help towards a speedier solution
thank you kindly
- Brad