When executing this jsfl, a JavaScript error occurs

Participant ,
Feb 07, 2022 Feb 07, 2022

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));

}
TOPICS
ActionScript , Code , Error

Views

101

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

correct answers 1 Correct answer

Adobe Community Professional , Feb 19, 2022 Feb 19, 2022
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)); }

Likes

Translate

Translate
Adobe Community Professional ,
Feb 07, 2022 Feb 07, 2022

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.

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
Participant ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Thanks, is there a good solution

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 ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

use a for loop.

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
Participant ,
Feb 19, 2022 Feb 19, 2022

Copy link to clipboard

Copied

Can you give specific code help?

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 ,
Feb 19, 2022 Feb 19, 2022

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));
}

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
Participant ,
Feb 20, 2022 Feb 20, 2022

Copy link to clipboard

Copied

Can the effect in B be achieved?截屏2022-02-20 下午5.00.05.png

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 ,
Feb 20, 2022 Feb 20, 2022

Copy link to clipboard

Copied

LATEST

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));
}

 

 

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