Changing the strokeWidth using strokeColor
I'm new to JavaScript, and I'm having some difficulty. I've got some existing knowledge of python, but I've found it's rather different. I'm trying to figure out how to change the stroke width for a path based on it's color. There is a simplified version of my script below.
For some reason it never recognizes the color of the path. I've tried comparing the color class I created with the stroke color, but that never works. I've also tried doing a comparison of all the different RGB components of the color, but that gives me an error. If I add path.strokeColor.RGBColor.red I get an error saying that "undefined is not an object".
The RGB color class should have a red component, right? I don't understand why it's undefined.
Does anybody have any thoughts?
if (documents.length > 0 && activeDocument.pathItems.length > 0){
// Gets all the paths in the document
var allPaths = activeDocument.pathItems;
// This is the color I want to find, red
var red = new RGBColor();
red.red = 233;
red.green = 38;
red.blue = 41;
// Change the stroke of the path if it's a red line
for (var l=0; l < allPaths.length; l++) {
// select only red paths
if (allPaths
.strokeColor.RGBColor.red == red.red) { allPaths
.strokeWidth = 10.0; }
}
}