Thanks kglad, yep it works to differentiate between the timeline and the array. Nearly there I think.. In order to copy and paste between a library item and the current timeline, the following code iterates over the library item's timeline selecting a layer and copying some frames and then looks for the same layer name in the current timline to paste into. But when the following is run, nothing is pasted except an empty keframe on the currently selected layer (in this case, 1 of 20 layers). var dom = fl.getDocumentDOM();
var tl = dom.getTimeline();
var layers = tl.layers;
// Define the library item
var pName = String(tl.name + '/puppet/' + tl.name + '_poses')
dom.library.selectItem(pName)
var copyTL = dom.library.getSelectedItems()[0].timeline;
var copyTLArray = dom.library.getSelectedItems()[0].timeline[1];
// Copy and Paste Details
// Copy
var cFrom = 1
var cTo = 2
var pFrom = tl.currentFrame
var pTo = pFrom + (cTo - cFrom)
// Iterate Over copyTL and copy frames to paste into tl
for (i = 0; i < copyTLArray.length; i++) {
// Copy frames from copyTL
copyTL.currentLayer = i;
copyTL.setSelectedFrames(cFrom, cTo);
copyTL.copyFrames(cFrom, cTo+1);
// Select layer in tl based on name of copyTL[i].name
var index = tl.findLayerIndex(copyTLArray[i].name);
if (!index) {
fl.trace("No layer called + " + copyTLArray[i].name)
}
else {
tl.currentLayer = index
tl.setSelectedFrames(pFrom, pTo);
tl.pasteFrames(pFrom, pTo+1);
}
} Any ideas why nothing is being pasted?
... View more