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

How does determine whether the current frame is a Keyframe?

Participant ,
May 19, 2023 May 19, 2023

Copy link to clipboard

Copied

I wrote a simple command that needed to use an if statement to determine the condition. I checked the manual, but I couldn't find an example of judging keyframes.
The ideas are as follows:

 

//Select the current frame.
//Condition judgment:
if (if the current frame equals a Keyframe) {
//execute Command 1
} else {
//if the current frame is not a Keyframe, add a Keyframe and execute command 2
}

The stupid code I wrote can run, but will make an error in the first frame of the layer.
thank you very much!!

 

TOPICS
Code

Views

323

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 , May 19, 2023 May 19, 2023

var doc = fl.getDocumentDOM();
var tl = doc.getTimeline();
//Select the current frame
var c = tl.currentFrame;

// should error check that only one layer is selected
if(c== tl.layers[tl.getSelectedLayers()[0]].frames[c].startFrame){
// do whatever
}

Votes

Translate

Translate
Community Expert ,
May 19, 2023 May 19, 2023

Copy link to clipboard

Copied

var doc = fl.getDocumentDOM();
var tl = doc.getTimeline();
//Select the current frame
var c = tl.currentFrame;

// should error check that only one layer is selected
if(c== tl.layers[tl.getSelectedLayers()[0]].frames[c].startFrame){
// do whatever
}

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
Participant ,
May 19, 2023 May 19, 2023

Copy link to clipboard

Copied

Perfect problem-solving! Thank you.

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 ,
May 19, 2023 May 19, 2023

Copy link to clipboard

Copied

LATEST

you're welcome.

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