A JSFL command to change the RGB% values of advanced color effects of a symbol
I will admit I tried Google Gemini for some assistance in code, but the code does run, but there is no changes to the color at all, I got an example code here after some difficulty.
function randomizeAdvancedColor() {
var dom = fl.getDocumentDOM();
if (!dom) {
fl.trace("Please open an Adobe Animate document.");
return;
}
var selection = dom.selection;
if (!selection || selection.length === 0) {
fl.trace("No items are selected. Select one or more MovieClip or Graphic instances.");
return;
}
// Check for syntax error here (Likely line 20)
for (var i = 0; i < selection.length; i++) {
var element = selection[i];
if (element.instanceType === "symbol") {
var rgbMultipliers = getRandomConstrainedRGB();
var rM = rgbMultipliers[0];
var gM = rgbMultipliers[1];
var bM = rgbMultipliers[2];
var newColorMatrix = [
rM, 0, 0, 0, 0,
0, gM, 0, 0, 0,
0, 0, bM, 0, 0,
0, 0, 0, 1, 0
];
element.colorEffect = {
'id': 'advanced',
'colorMatrix': newColorMatrix
};
}
}
dom.zoom = dom.zoom;
fl.trace("Successfully applied random constrained Advanced Color Effects to " + selection.length + " selected instances.");
}When I did other codes for tasks such as unselecting half of objects, or changing rotation transform to a random degree, those worked, but anything related to "color effects" on a symbol does nothing at all. Is there something I'm doing wrong? I only am trying to make my editing fast so I don't have to manually set tint colors to like 50 objects on a stage.
