-
Notifications
You must be signed in to change notification settings - Fork 0
/
Next Cel.jsfl
33 lines (29 loc) · 1.2 KB
/
Next Cel.jsfl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var fl = flash;
var theDocument = fl.getDocumentDOM();
var theTimeline = theDocument.getTimeline();
var currentLayerIndex = theTimeline.currentLayer;
var currentFrameIndex = theTimeline.currentFrame;
// Find the next keyframe on the right or the first keyframe on the layer
var nextKeyframeIndex = findNextKeyframe(currentLayerIndex, currentFrameIndex);
// Move to the next keyframe if found
if (nextKeyframeIndex !== -1) {
theTimeline.currentFrame = nextKeyframeIndex;
} else {
alert("No next keyframe found on this layer.");
}
// Function to find the next keyframe on the right or the first keyframe on the layer
function findNextKeyframe(layerIndex, startFrame) {
var frames = theTimeline.layers[layerIndex].frames;
for (var i = startFrame + 1; i < frames.length; i++) {
if (i === frames[i].startFrame) {
return i; // Found the next keyframe
}
}
// If no keyframe found to the right, find the first keyframe on the layer
for (var j = 0; j < frames.length; j++) {
if (j === frames[j].startFrame) {
return j; // Found the first keyframe on the layer
}
}
return -1; // Return -1 if no keyframe found
}