Skip to main content
DigitalDesignDude
Inspiring
September 10, 2024
Answered

Unparent Layers With JSFL?

  • September 10, 2024
  • 2 replies
  • 2025 views

Is it possible to un-parent layers while retaining their position using JSFL?

I have some projects that use classic tweened symbols with layer parenting, which I would like to bake and archive so that they can still be opened and exported using my copy of Flash CS6, without symbol offset issues.   

I originally planned to bake the animations using Animate's "Convert to Frame-by-Frame Animation" right click option, so that the symbols' movements will be preserved after un-parenting them. However, this would result in countless keyframes that would manually have to be unlinked from their parent layers, unless an automated solution is possible.

 

And from my testing, turning off "use advance layers" in the document settings does not prevent layer parented symbols from becoming offset in versions of Flash/Animate that do not support layer parenting.   

That leads me to these JSFL methods which might offer a less manual way to un-parent all those baked keyframes, but so far, I have not been successful with using layer.setRigParentAtFrame() to un-parent any layers.

If any assistance could be provided, I would highly appreciate it, and I thank you in advance for your time.

Correct answer DigitalDesignDude

I figured it out 🙂 

It turns out the documentation is possibly out of date or there is an error in it, as I could not get its example code to work in Animate version 24.0. If it helps anyone else out, below is example JSFL code on how you can use layer.setRigParentAtFrame()  to unset layer parenting for a given frame.

 

var tl = fl.getDocumentDOM().getTimeline(); //The document's timeline
var layerIndex = 0; //Index of the first layer
var frameNumber = 0; // Index of the first frame 

//Create a temporary layer to be deleted later
var tempLayer = tl.addNewLayer('TempLayer', "normal", false);

//Change the frame's layer parent to be the temp layer
tl.layers[layerIndex].setRigParentAtFrame(tempLayer, frameNumber)

//Delete the temp layer which will also remove layerparenting from its linked frame
tl.deleteLayer(tempLayer);

 


From my testing, there doesn't seem to be a way to set a Null layer parent, so creating a temporary layer to act as a new parent and then deleting the layer will remove the layer parenting connection without noticeable symbol displacement. 

2 replies

eytanrose
Inspiring
January 18, 2025

This Command will remove the rig parenting in all the selected frames (If no frames are selected - all rig-parenting in the timeline will be romoved):

var doc = fl.getDocumentDOM();
var tl = doc.getTimeline();
var selFrames = tl.getSelectedFrames();
if (selFrames.length == 0) {
	tl.selectAllFrames();
	selFrames = tl.getSelectedFrames();
}
var lay, ly, ef, sf;
for (i = selFrames.length - 3; i > -1; i -= 3) {
	ly = selFrames[i];
	lay = tl.layers[ly];
	if (lay.layerType == "folder") {
		continue;
	} else {
		sf = selFrames[i + 1];
		ef = selFrames[i + 2] - 1;
		for (f = ef; f > sf - 1; f -= 1) {
			var ff = lay.frames[f].startFrame;
			if (ff < sf) {
				break;
			} else {
				f = ff;
			}
			lay.setRigParentAtFrame(ly, f);
		}
	}
}
Participant
July 21, 2025

Hello,

Do you know where can i found documentation about "parenting" with jsfl ?
Actually i used "Extending "ADOBE FLASH PROFESSIONAL" but the last update is 2013 and that doesn't talk about "parenting"

kglad
Community Expert
Community Expert
July 21, 2025
DigitalDesignDude
DigitalDesignDudeAuthorCorrect answer
Inspiring
September 12, 2024

I figured it out 🙂 

It turns out the documentation is possibly out of date or there is an error in it, as I could not get its example code to work in Animate version 24.0. If it helps anyone else out, below is example JSFL code on how you can use layer.setRigParentAtFrame()  to unset layer parenting for a given frame.

 

var tl = fl.getDocumentDOM().getTimeline(); //The document's timeline
var layerIndex = 0; //Index of the first layer
var frameNumber = 0; // Index of the first frame 

//Create a temporary layer to be deleted later
var tempLayer = tl.addNewLayer('TempLayer', "normal", false);

//Change the frame's layer parent to be the temp layer
tl.layers[layerIndex].setRigParentAtFrame(tempLayer, frameNumber)

//Delete the temp layer which will also remove layerparenting from its linked frame
tl.deleteLayer(tempLayer);

 


From my testing, there doesn't seem to be a way to set a Null layer parent, so creating a temporary layer to act as a new parent and then deleting the layer will remove the layer parenting connection without noticeable symbol displacement. 

JoãoCésar17023019
Community Expert
Community Expert
September 12, 2024

Great.

 

Thanks for sharing!

 

Regards,

JC