diff --git a/CHANGELOG.md b/CHANGELOG.md index fbd66be25..7dbb5adec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Exception when switching from nonribbon interface to ribbon - [#1396], [#1254] FLA Export - AS3 frame scripts +- FLA Export - mutliple FrameLabel layers ## [14.1.0] - 2021-03-05 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 291f11172..d62cc53ea 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -2169,6 +2169,7 @@ public class XFLConverter { writer.writeEndElement(); // SoundEnvelope } } + private static void convertFrame(boolean shapeTween, SoundStreamHeadTypeTag soundStreamHead, StartSoundTag startSound, int frame, int duration, String actionScript, String elements, HashMap files, XFLXmlWriter writer) throws XMLStreamException { DefineSoundTag sound = null; if (startSound != null) { @@ -2696,25 +2697,40 @@ public class XFLConverter { private boolean convertLabelsLayer(int spriteId, ReadOnlyTagList tags, ReadOnlyTagList timeLineTags, String backgroundColor, XFLXmlWriter writer) throws XMLStreamException { boolean hasLabel = false; - int duration = 0; + Map> frameToLabels = new HashMap<>(); int frame = 0; - String frameLabel = ""; - boolean isAnchor = false; + int layerCount = 0; for (Tag t : timeLineTags) { if (t instanceof FrameLabelTag) { - FrameLabelTag fl = (FrameLabelTag) t; - frameLabel = fl.getLabelName(); - isAnchor = fl.isNamedAnchor(); + FrameLabelTag frameLabel = (FrameLabelTag) t; + if (!frameToLabels.containsKey(frame)) { + frameToLabels.put(frame, new ArrayList<>()); + } + frameToLabels.get(frame).add(frameLabel); + if (frameToLabels.get(frame).size() > layerCount) { + layerCount = frameToLabels.get(frame).size(); + } } else if (t instanceof ShowFrameTag) { - if (frameLabel.isEmpty()) { + frame++; + } + } + int frameCount = frame; + + for (int lay = 0; lay < layerCount; lay++) { + writer.writeStartElement("DOMLayer", new String[]{"name", "Labels Layer" + (layerCount > 1 ? " " + (lay + 1) : ""), "color", randomOutlineColor()}); + writer.writeStartElement("frames"); + int duration = 0; + for (int i = 0; i < frameCount; i++) { + List frameLabels = frameToLabels.get(i); + FrameLabelTag frameLabel = null; + if (frameLabels != null) { + if (frameLabels.size() > lay) { + frameLabel = frameLabels.get(lay); + } + } + if (frameLabel == null) { duration++; } else { - if (!hasLabel) { - writer.writeStartElement("DOMLayer", new String[]{"name", "Labels Layer", "color", randomOutlineColor()}); - writer.writeStartElement("frames"); - hasLabel = true; - } - if (duration > 0) { writer.writeStartElement("DOMFrame", new String[]{"index", Integer.toString(frame - duration)}); if (duration > 1) { @@ -2724,11 +2740,10 @@ public class XFLConverter { writer.writeElementValue("elements", ""); writer.writeEndElement(); } - writer.writeStartElement("DOMFrame", new String[]{"index", Integer.toString(frame)}); writer.writeAttribute("keyMode", KEY_MODE_NORMAL); - writer.writeAttribute("name", frameLabel); - if (isAnchor) { + writer.writeAttribute("name", frameLabel.name); + if (frameLabel.namedAnchor) { writer.writeAttribute("labelType", "anchor"); writer.writeAttribute("bookmark", true); } else { @@ -2736,14 +2751,10 @@ public class XFLConverter { } writer.writeElementValue("elements", ""); writer.writeEndElement(); - frameLabel = ""; duration = 0; } - frame++; - } - } - if (hasLabel) { + } writer.writeEndElement(); // frames writer.writeEndElement(); // DOMLayer } diff --git a/libsrc/ffdec_lib/testdata/as3_frames/exported/LIBRARY/Symbol 3.xml b/libsrc/ffdec_lib/testdata/as3_frames/exported/LIBRARY/Symbol 3.xml new file mode 100644 index 000000000..352ac80a3 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_frames/exported/LIBRARY/Symbol 3.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/as3_frames/exported/LIBRARY/Symbol 5.xml b/libsrc/ffdec_lib/testdata/as3_frames/exported/LIBRARY/Symbol 5.xml new file mode 100644 index 000000000..cf217c40a --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_frames/exported/LIBRARY/Symbol 5.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/as3_frames/exported/LIBRARY/bitmap1.png b/libsrc/ffdec_lib/testdata/as3_frames/exported/LIBRARY/bitmap1.png new file mode 100644 index 000000000..15a544e4d Binary files /dev/null and b/libsrc/ffdec_lib/testdata/as3_frames/exported/LIBRARY/bitmap1.png differ diff --git a/libsrc/ffdec_lib/testdata/as3_frames/exported/acorn.as b/libsrc/ffdec_lib/testdata/as3_frames/exported/acorn.as new file mode 100644 index 000000000..82d672a8b --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_frames/exported/acorn.as @@ -0,0 +1,15 @@ + +package +{ + import flash.display.BitmapData; + + public dynamic class acorn extends BitmapData + { + + + public function acorn(param1:int = 32, param2:int = 32) + { + super(param1,param2); + } + } +}