0
Empty layer
Explorer
,
/t5/animate-discussions/empty-layer/td-p/11610360
Nov 19, 2020
Nov 19, 2020
Copy link to clipboard
Copied
Hello.
Is there a way to delete all empty layers on adobe animate?
Thanks
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/empty-layer/m-p/11610659#M337706
Nov 19, 2020
Nov 19, 2020
Copy link to clipboard
Copied
Hi.
This script should be able to remove all layers in a document.
WARNING:
Please save your document first and also make a backup of it in case of an unwanted result or errors.
var dom, libray, items, layersCount, deleted;
var symbols = ["button", "graphic", "movie clip"];
function main()
{
dom = fl.getDocumentDOM();
if (!dom)
{
alert("Please open up a document first.");
return;
}
var i, total;
library = dom.library;
items = library.items;
layersCount = 0;
deleted = 0;
searchLibrary();
for (i = 0, total = dom.timelines.length; i < total; i++)
searchTimeline(dom.timelines[i]);
alert(deleted + " layers of " + layersCount + " have been deleted");
}
function searchLibrary()
{
var i, total, item;
for (i = 0, total = items.length; i < total; i++)
{
item = items[i];
if (symbols.indexOf(item.itemType) > -1)
searchTimeline(item.timeline);
}
}
function searchTimeline(timeline)
{
var layers = timeline.layers.reverse();
var count = 0;
var i, total, layer;
for (i = 0, total = layers.length; i < total; i++)
{
layer = layers[i];
layersCount++;
count++;
if (layer.layerType !== "folder")
{
var isEmpty = layer.frames.every(function(frame)
{
return frame.isEmpty;
});
if (isEmpty)
{
timeline.deleteLayer(total - count);
deleted++;
}
}
}
}
main();
Usage:
1 - Just copy and paste it in a text editor and save it with a .jsfl extension or just grab it from the link below.
2 - Double-click the JSFL file or drag and drop it over Animate or go to Commands... > Run Command...
File / source / JSFl download:
I hope it helps.
Regards,
JC
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Pedro H. Oliveira
AUTHOR
Explorer
,
/t5/animate-discussions/empty-layer/m-p/11612090#M337719
Nov 20, 2020
Nov 20, 2020
Copy link to clipboard
Copied
Thanks!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
LATEST
/t5/animate-discussions/empty-layer/m-p/11612367#M337723
Nov 20, 2020
Nov 20, 2020
Copy link to clipboard
Copied
You're welcome!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

