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

Jsfl script for Property of a keyframe

Community Beginner ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

Hello, I have a question, I need a script to put a Name label that in this case would be numbers in a Keyframe. Number ranging from 1 to 205. Basically it would be a jsfl script. It would see which keyframes on the timeline I'm selecting and when I run it it would put the property; label Name > 1 > 2 > 3 and then it would go to each individual keyframe in sequence. I have a script but it not work yet., if necessary I can try to share it


TOPICS
ActionScript , Code , Timeline

Views

1.1K

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

Contributor , Apr 20, 2023 Apr 20, 2023

I did not understand what exactly you need, but I sketched a small script that marks the keyframes

 

 

 

 

var dom = fl.getDocumentDOM()
var tl = dom.getTimeline()
var selectFrames = tl.getSelectedFrames();

for (var i = 0; i < selectFrames.length; i += 3) {
	for (var a = selectFrames[(i + 1)]; a < selectFrames[(i + 2)]; a++) {
		var objectFrames = tl.layers[selectFrames[(i)]].frames[a]
		if (objectFrames.startFrame == a) {
			objectFrames.name = a + 1;
		}
	}
}

 

 

 

Let's start small, if anything, I'll

...

Votes

Translate

Translate
Community Expert ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

using name labels that look like numbers (even though they are strings and this can be done) is unwise.

 

and it's not clear to me what problem you're having.  are you selecting only keyframes?  do you need a script to find keyframes?  something else?

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 Beginner ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

Thanks for the answer. I've given a slightly better example below!

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 ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

10 frames?  looks like 205+ frames and there's no check to see if keyframes are selected.

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 Beginner ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

Then. It was an example, the plan is for it to name the selected keyframes. there is a fixed example of 205, but the exemple is that can add a number label depending on the number of selected keyframes and name it 1, 2, 3...  I don't mess with code, so I don't know how functional it is! it was just to have a base of what i'm trying to do

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 ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

ok. then what problem do you see?

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 Beginner ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

I select an amount of 205 empty keyframes to check. when running it returns the following error: fl.getTimelineSelect is not a function

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 ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

I did not understand what exactly you need, but I sketched a small script that marks the keyframes

 

 

 

 

var dom = fl.getDocumentDOM()
var tl = dom.getTimeline()
var selectFrames = tl.getSelectedFrames();

for (var i = 0; i < selectFrames.length; i += 3) {
	for (var a = selectFrames[(i + 1)]; a < selectFrames[(i + 2)]; a++) {
		var objectFrames = tl.layers[selectFrames[(i)]].frames[a]
		if (objectFrames.startFrame == a) {
			objectFrames.name = a + 1;
		}
	}
}

 

 

 

Let's start small, if anything, I'll finalize it

 

 

 

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 Beginner ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

thanks!! 😍. This works perfectly. 

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 ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

Super, this is what you need or need to somehow supplement the code?

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 Beginner ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

LATEST

It already works the way I need it!! Thanks

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 ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

Could you please show your script

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 Beginner ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

script to name selected keyframes with Number Labels. The plan is that it will add a value to each Keyframe selected in the property like this: if I have 10 keyframes selected in the timeline it will add Name/Labels going from 1 to 10. >  in this example it is an anchor label.

ankz988_0-1682051214484.png
The script I'm trying is like this: 

Define a function that renames selected frames
function renameSelectedFrames() {
  // Get current frame selection
  var selection = fl.getTimelineSelect();

  // Make sure a frame is selected
  if (selection.length === 0) {
    alert("Select some frames before running this script.");
    fl.trace("No frame selected.");
    return false;
  }

  // Check if the selection contains less than 205 frames
  if (selection.length < 205) {
    alert("Select at least 205 frames before running this script.");
    fl.trace("Insufficient selection.");
    return false;
  }

  // Rename each selected frame with a number from 1 to 205
  for (var i = 0; i < selection.length; i++) {
    var frame = selection[i];
    var name = (i % 205) + 1; // get a number from 1 to 205
    fl.setFrameName(frame, name.toString());
  }

  // Confirm that the operation completed successfully

  alert("Frames have been successfully renamed.");
  fl.trace("Frames have been successfully renamed.");
  return true;
}

// Call function to rename selected frames
renameSelectedFrames();



 

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