Answered
preflight snippet help
i need a bit of help with this snippet...
i wrote this as part of a preflight script to check for RGB and spot colors
on some (NOT ALL) files that had offending colors, it still flags as having an incorrect swatch even after i have corrected the issue... but gives no name in the alert. could someone look it over to see where i am missing something?
var myDoc = app.activeDocument;
var rgbSwatchExists = false;
var spotColorsPresent = false;
var offendingColors = []; // Array to store names of offending colors
var allSwatches = myDoc.colors.everyItem().getElements();
for (var i = 0; i < allSwatches.length; i++) {
if (allSwatches[i].space === ColorSpace.RGB) {
rgbSwatchExists = true;
offendingColors.push(allSwatches[i].name); // Store name of RGB color
}
}
for (var j = 0; j < myDoc.colors.length; j++) {
var color = myDoc.colors[j];
if (color.model == ColorModel.SPOT) {
spotColorsPresent = true;
offendingColors.push(color.name); // Store name of spot color
}
}
if (rgbSwatchExists || spotColorsPresent) {
var message = "RGB or spot colors swatches are present:\n";
for (var k = 0; k < offendingColors.length; k++) {
message += "+ " + offendingColors[k] + "\n";
}
var userResponse = confirm(message + "\nDo you want to continue?");
if (!userResponse) {
exit();
}
}


