• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

When executing this jsfl, a JavaScript error occurs

Contributor ,
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

236

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

Community Expert , 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));
}

Votes

Translate

Translate
Community Expert ,
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.

Votes

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

Copy link to clipboard

Copied

Thanks, is there a good solution

Votes

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

Copy link to clipboard

Copied

use a for loop.

Votes

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

Copy link to clipboard

Copied

Can you give specific code help?

Votes

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
Community Expert ,
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));
}

Votes

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
Contributor ,
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

Votes

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
Community Expert ,
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));
}

 

 

Votes

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