我已经做了一些调查,从我读过似乎在JSFL没有类似的Flash IDE中的“选择未使用的项目”“使用计数”。检查库项目与JSFL
有谁知道至少能够检查属性,如果该项目被用于通过全库骑自行车吗?像item.useCount ...
我检查的Adobe文件和我无法找到任何东西...
我已经做了一些调查,从我读过似乎在JSFL没有类似的Flash IDE中的“选择未使用的项目”“使用计数”。检查库项目与JSFL
有谁知道至少能够检查属性,如果该项目被用于通过全库骑自行车吗?像item.useCount ...
我检查的Adobe文件和我无法找到任何东西...
编辑:所以我只跨过选择的闲置物品这个整洁的小菜单项来了。 ..不需要JSFL。它隐藏在库面板头部的上下文下拉菜单中。点击该下拉菜单并点击“选择未使用的项目”。 Flash将选择所有未使用的库项目,它甚至会跳过具有动态实例化链接名称的项目。所以这真的取决于你......你可以使用这个方法或下面的脚本。
我不能充分信贷的代码你看到下面的,因为我是把一些代码,我从位于这里现有的脚本碰到:
因为它的存在会检查该脚本使用手动选择的库项目的数量。它在设计上非常聪明,它甚至检查项目是否包含链接名称,但可能不一定在舞台上。这是为了确保您不会删除任何可能动态实例化的项目。我所做的是我将现有的代码放在for循环中,该循环根据循环的当前项目运行检查。
// Remove Unused Library Symbols
var dom = fl.getDocumentDOM();
if (dom == null)
{
alert('Please open a file.');
}
else
{
var lib = dom.library;
var activeItem;
var isFound;
var item;
var libItems = lib.items;
fl.outputPanel.clear();
for (var i = 0; i < libItems.length; i++)
{
var curLibItemName = libItems[i].name;
var curLibItemSelection = lib.selectItem(curLibItemName, true, true);
var selectedItem = lib.getSelectedItems();
function scanTimeline(_timeline, _mainTimeline)
{
var timeline = _timeline;
var layerCount = timeline.layerCount;
while (layerCount--)
{
var frameCount = timeline.layers[layerCount].frameCount;
while (frameCount--)
{
if (timeline.layers[layerCount].frames[frameCount] == undefined)
{
continue;
}
var elems = timeline.layers[layerCount].frames[frameCount].elements;
var p = elems.length;
while (p--)
{
// Check if it's an instance in the library
if (elems[p].elementType == 'instance')
{
// Check if it's the same clip as our active check
if (elems[p].libraryItem.name == activeItem.name)
{
found = true;
var where;
if(_mainTimeline == true)
{
where = 'Located in the main timeline.';
}
else
{
where = 'Located in the library item: ' + item.name;
}
frameCount = 0;
}
}
}
}
}
}
function scanLibrary()
{
var items = lib.items;
for (var i = 0; i < items.length; i++)
{
item = items[i];
if(item.itemType == 'movie clip')
{
scanTimeline(item.timeline, false);
}
}
}
// Safety check
if (selectedItem.length == 0)
{
alert('Please make a selection in the library.');
}
else
{
activeItem = selectedItem[0];
found = false;
// Scan the main timeline first
scanTimeline(dom.getTimeline(), true);
// Scan the library
scanLibrary();
if (found == false)
{
if (activeItem.linkageClassName != undefined)
{
fl.trace(curLibItemName + ' was not found on the stage, but it does have a linkage name so it may be instantiated dynamically. Use caution before deleting.');
}
else
{
fl.trace(curLibItemName + ' was not found on the stage and will be removed.');
lib.deleteItem(curLibItemName);
}
}
}
}
}
正如我提到的,我不能把所有的功劳,是因为剧本的原始开发商做了大部分繁重的这个命令的。在包含原始代码的FUEL页面中,似乎Julian Dolce负责这项工作。原始码的许可证是MIT许可证(MIT)。
您可以从上面的代码复制到一个新的JSFL文件并将其保存在您的命令文件夹或从下面的链接下载该文件JSFL并将其放置在你的命令的文件夹。
Download: Remove Unused Library Symbols.jsfl
我希望帮助。
选择未使用的库项目 - Flash Pro中CC
var unusedArr = fl.getDocumentDOM().library.unusedItems;
for(var i=0;i<unusedArr.length;i++)
fl.getDocumentDOM().library.selectItem(unusedArr[i].name,false,true);
fl.trace(unusedArr.length+' Items selected');