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

Unparent Layers With JSFL?

Participant ,
Sep 09, 2024 Sep 09, 2024

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.

TOPICS
Code
1.9K
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

Participant , Sep 11, 2024 Sep 11, 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 t
...
Translate
Participant ,
Sep 11, 2024 Sep 11, 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. 

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 ,
Sep 12, 2024 Sep 12, 2024

Great.

 

Thanks for sharing!

 

Regards,

JC

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
New Here ,
Sep 23, 2024 Sep 23, 2024

I found that the following method can be used to achieve this without creating a new layer.

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


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

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 Beginner ,
Oct 19, 2024 Oct 19, 2024

Hello, I have a question about the parent layer. I have set the parent-child layer relationship in the layer. Moving the parent layer rotation in the document stage can drive the children to move together. I control the rotation property of the parent in jsfl. Why can't I move the child on its behalf? Is there any way to implement code to control the rotation of the parent?

 

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
Participant ,
Oct 19, 2024 Oct 19, 2024

I had a similar issue when attempting to move a parent layer using ActionScript below:
Layer Parenting, Child Layers Not Moving with Pare... - Adobe Community - 14185201

It seems JSFL also cannot take advantage of layering parenting, possibly for the same reason that was discussed in the above post. 

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 Beginner ,
Oct 19, 2024 Oct 19, 2024

Thank you, comrade. Since it can be achieved with doc, then I think there must be some complex relational expressions to control the displacement relationship of elements at the layer level. I will try to use code to simulate this kind of relational expression.

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
Explorer ,
Jan 18, 2025 Jan 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);
		}
	}
}
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
New Here ,
Jul 21, 2025 Jul 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"

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 ,
Jul 21, 2025 Jul 21, 2025
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
New Here ,
Jul 23, 2025 Jul 23, 2025

Thank you ! Does it exist in PDF format ?

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 ,
Jul 23, 2025 Jul 23, 2025
LATEST

i don't know.

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