Copy link to clipboard
Copied
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.
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
...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Great.
Thanks for sharing!
Regards,
JC
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
}
}
}
Copy link to clipboard
Copied
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"
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thank you ! Does it exist in PDF format ?
Copy link to clipboard
Copied
i don't know.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now