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!!
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
}
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
}
Copy link to clipboard
Copied
Perfect problem-solving! Thank you.
Copy link to clipboard
Copied
you're welcome.