Copy link to clipboard
Copied
It's possible to select objects by color. It is for the option to select a scene of strokes with different colors. I want to select all those with the same color with edit multiple frames.
Copy link to clipboard
Copied
Depending on what you want to do to those strokes, you may be able to use Find And Replace Strokes.
Copy link to clipboard
Copied
I have tried, but the option is to select the stroke with green color and delete. And keep the red stroke.
Thanks!
Copy link to clipboard
Copied
I found this code that works in Flash CS6, but not in Animate 2021-22
var dom = fl.getDocumentDOM();
var timeline = dom.getTimeline();
/*
MODIFY THE KEYS IN THIS TABLE.
*/
var coloursToDelete = {
'FF0000': true,
'FFFF00': true,
};
var replacements;
var srcColour;
var layerName;
// Make sure all colours are lowercase and start with a #
for(var colour in coloursToDelete)
{
var val = coloursToDelete[colour];
delete coloursToDelete[colour];
if(colour[0] !== '#')
colour = '#' + colour;
coloursToDelete[colour.toLowerCase()] = val;
}
// Make sure to clear the selection, or the script will crash?
dom.selectNone();
fl.outputPanel.clear();
var deleteCount = 0;
// ----------------------------------------------------
// Loop through all layers
for(var layerIndex in timeline.layers)
{
var layer = timeline.layers[layerIndex];
if(!layer.visible)
continue;
// ----------------------------------------------------
// Loop through all frames of the current layer
for(var frameIndex = 0; frameIndex < timeline.frameCount; frameIndex++)
{
var frameDeleteCount = 0;
var frame = layer.frames[frameIndex];
if(!frame)
continue;
// ----------------------------------------------------
// Loop through all elements in the current frame
for(var elementIndex in frame.elements)
{
var element = frame.elements[elementIndex];
if(!element)
continue;
if(element.elementType !== 'shape')
continue;
// ----------------------------------------------------
// Check each edge in the current shape
for(var edgeIndex in element.edges)
{
var edge = element.edges[edgeIndex];
var stroke = edge.stroke;
var fill = stroke ? stroke.shapeFill : null;
if(!fill)
continue;
if(fill.color in coloursToDelete)
{
stroke.shapeFill = null;
edge.stroke = fill;
deleteCount++;
frameDeleteCount++;
}
}
}
// A quirk of deleting strokes like this is that shapes won't automatically merge like they would when deleting a stroke in the editor.
// Selecting then deselecting will force this to happen
if(frameDeleteCount > 0)
{
dom.selectAll();
dom.selectNone();
}
}
}
fl.trace('-- ' + dom.name + ': Deleted ' + (deleteCount) + ' strokes.');
Copy link to clipboard
Copied
If search and replace allowed to use replace by an empty color it could be used.