Copy link to clipboard
Copied
Achieving the typewriter effect
var doc = fl.getDocumentDOM();
doc.breakApart();
doc.distributeToLayers();
doc.selectAll();
var obs = doc.selection;
doc.getTimeline().insertFrames( obs.length * 2, true, 1);
var tl = doc.getTimeline();
var total = obs.length;
var i = total + 1;
while( i-- ){
tl.setSelectedLayers( total - i, true );
tl.cutFrames(0);
tl.pasteFrames( i * 2 );
tl.clearFrames(0, (i * 2));
}
var doc = fl.getDocumentDOM();
doc.breakApart();
doc.distributeToLayers();
doc.selectAll();
var obs = doc.selection;
doc.getTimeline().insertFrames( obs.length * 2, true, 1);
var tl = doc.getTimeline();
var total = obs.length;
for(i=1;i<total;i++){
tl.setSelectedLayers( total - i, true );
tl.cutFrames(0);
tl.pasteFrames( i * 2 );
tl.clearFrames(0, (i * 2));
}
Copy link to clipboard
Copied
tl.setSelectedLayers( total - i, true );
is going to be out of range when i=0. ie, don't use while loops unless you really know what you're doing and are certain you're not going to make a mistake. eg, i never use while loops because i know i make mistakes.
Copy link to clipboard
Copied
Thanks, is there a good solution
Copy link to clipboard
Copied
use a for loop.
Copy link to clipboard
Copied
Can you give specific code help?
Copy link to clipboard
Copied
var doc = fl.getDocumentDOM();
doc.breakApart();
doc.distributeToLayers();
doc.selectAll();
var obs = doc.selection;
doc.getTimeline().insertFrames( obs.length * 2, true, 1);
var tl = doc.getTimeline();
var total = obs.length;
for(i=1;i<total;i++){
tl.setSelectedLayers( total - i, true );
tl.cutFrames(0);
tl.pasteFrames( i * 2 );
tl.clearFrames(0, (i * 2));
}
Copy link to clipboard
Copied
Can the effect in B be achieved?
Copy link to clipboard
Copied
oops, my error. use:
var doc = fl.getDocumentDOM();
doc.breakApart();
doc.distributeToLayers();
doc.selectAll();
var obs = doc.selection;
doc.getTimeline().insertFrames( obs.length * 2, true, 1);
var tl = doc.getTimeline();
var total = obs.length;
for(i=1;i<=total;i++){
tl.setSelectedLayers( total - i, true );
tl.cutFrames(0);
tl.pasteFrames( i * 2 );
tl.clearFrames(0, (i * 2));
}