Empty layer

Community Beginner ,
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

Views

80

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
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:

https://bit.ly/2IQaYIw

 

I hope it helps.

 

Regards,

JC

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 20, 2020 Nov 20, 2020

Copy link to clipboard

Copied

Thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 20, 2020 Nov 20, 2020

Copy link to clipboard

Copied

LATEST

You're welcome!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines