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

How does determine whether the current frame is a Keyframe?

Contributor ,
May 19, 2023 May 19, 2023

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
753
Translate
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
}

Translate
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
}

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

Perfect problem-solving! Thank you.

Translate
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
LATEST

you're welcome.

Translate
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