如何将影片剪辑中的所有帧转换为关键帧?

时间:2012-11-28 15:36:37

标签: flash automation jsfl flash-ide

如何自动将使用Classic Tween的库中的所有Movie Clip(SymbolItem)项目转换为关键帧?

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以使用Adobe Flash Professional CS4及更高版本支持的 JSFL 脚本

可以在此处找到文档:http://help.adobe.com/en_US/flash/cs/extend/index.html

var document = fl.getDocumentDOM();

var library = document.library;

for (var libraryItemIndex in library.items) {
    var libraryItem = library.items[libraryItemIndex];

    fl.trace(libraryItem.name + " is " + libraryItem.itemType);

    if(libraryItem.itemType == "movie clip") {

        fl.trace(" processing movie clip");

        library.selectItem(libraryItem.name);
        library.editItem(libraryItem.name);

        var timeline = libraryItem.timeline;

        fl.trace(" contains " + timeline.layerCount + " layers");
        fl.trace(" selected layers " + timeline.getSelectedLayers());

        for (var layerIndex in timeline.layers) {
            fl.trace(" trying to select layer " + layerIndex);
            timeline.setSelectedLayers(Number(layerIndex));
            fl.trace(" converting to key frames");
            timeline.convertToKeyframes(0, libraryItem.timeline.frameCount - 1);
        }
    }
    else {
        fl.trace(" ignoring");
    }
}

输出将如下所示:

enter image description here

注意:注意方法timeline.setSelectedLayers(),强制转换为Number