From 9f1970fdfabedb96c629495a06c284bb8881c4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 3 Nov 2022 21:33:00 +0100 Subject: [PATCH] Fixed #1860, #1732, #1837 FLA export - AS3 - missing framescripts on the timeline --- CHANGELOG.md | 3 +++ .../flash/abc/types/traits/TraitClass.java | 6 ++++- .../decompiler/flash/xfl/XFLConverter.java | 22 ++++++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bc83501a..1b296042d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. - [#1782] FLA export - exporting from SWF files inside bundles (like binarysearch) - Expand correct tree on SWF load - [#1679] FLA export - MorphShapes (shape tween) +- [#1860], [#1732], [#1837] FLA export - AS3 - missing framescripts on the timeline ## [16.0.3] - 2022-11-02 ### Fixed @@ -2461,6 +2462,8 @@ All notable changes to this project will be documented in this file. [#1860]: https://www.free-decompiler.com/flash/issues/1860 [#1782]: https://www.free-decompiler.com/flash/issues/1782 [#1679]: https://www.free-decompiler.com/flash/issues/1679 +[#1732]: https://www.free-decompiler.com/flash/issues/1732 +[#1837]: https://www.free-decompiler.com/flash/issues/1837 [#1817]: https://www.free-decompiler.com/flash/issues/1817 [#1816]: https://www.free-decompiler.com/flash/issues/1816 [#1859]: https://www.free-decompiler.com/flash/issues/1859 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 50d81a903..076559427 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.model.CallPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; @@ -282,7 +283,10 @@ public class TraitClass extends Trait implements TraitWithSlot { if ("addFrameScript".equals(propName.resolvedMultinameName)) { for (int i = 0; i < callProp.arguments.size(); i += 2) { if (callProp.arguments.get(i) instanceof IntegerValueAVM2Item) { - if (callProp.arguments.get(i + 1) instanceof GetPropertyAVM2Item) { + if (callProp.arguments.get(i + 1) instanceof GetLexAVM2Item) { + GetLexAVM2Item lex = (GetLexAVM2Item) callProp.arguments.get(i + 1); + frameTraitNames.add(abc.constants.getMultinameId(lex.propertyName, false)); + } else if (callProp.arguments.get(i + 1) instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item getProp = (GetPropertyAVM2Item) callProp.arguments.get(i + 1); if (getProp.object instanceof ThisAVM2Item) { if (getProp.propertyName instanceof FullMultinameAVM2Item) { 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 c79f73f73..75840ce2d 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 @@ -26,12 +26,14 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.avm2.model.CallPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; import com.jpexs.decompiler.flash.abc.types.ConvertData; import com.jpexs.decompiler.flash.abc.types.InstanceInfo; import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.flash.abc.types.traits.Trait; @@ -2629,7 +2631,7 @@ public class XFLConverter { try { constructorBody.convert(new ConvertData(), "??", ScriptExportMode.AS, false, constructorMethodIndex, pack.scriptIndex, classIndex, abc, null, new ScopeStack(), GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, new NulWriter(), new ArrayList<>(), new ArrayList<>(), true, new HashSet<>()); - Map frameToTraitMultiname = new HashMap<>(); + Map frameToTraitMultiname = new HashMap<>(); //find all addFrameScript(xx,this.method) in constructor /* @@ -2657,13 +2659,16 @@ public class XFLConverter { if (callProp.arguments.get(i) instanceof IntegerValueAVM2Item) { IntegerValueAVM2Item frameItem = (IntegerValueAVM2Item) callProp.arguments.get(i); int frame = frameItem.intValue(); - if (callProp.arguments.get(i + 1) instanceof GetPropertyAVM2Item) { + if (callProp.arguments.get(i + 1) instanceof GetLexAVM2Item) { + GetLexAVM2Item lex = (GetLexAVM2Item) callProp.arguments.get(i + 1); + frameToTraitMultiname.put(frame, lex.propertyName); + } else if (callProp.arguments.get(i + 1) instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item getProp = (GetPropertyAVM2Item) callProp.arguments.get(i + 1); if (getProp.object instanceof ThisAVM2Item) { if (getProp.propertyName instanceof FullMultinameAVM2Item) { FullMultinameAVM2Item framePropName = (FullMultinameAVM2Item) getProp.propertyName; int multinameIndex = framePropName.multinameIndex; - frameToTraitMultiname.put(frame, multinameIndex); + frameToTraitMultiname.put(frame, abc.constants.getMultiname(multinameIndex)); } } } @@ -2674,15 +2679,16 @@ public class XFLConverter { } } } - Map multinameToMethodTrait = new HashMap<>(); + Map multinameToMethodTrait = new HashMap<>(); for (Trait trait : instanceInfo.instance_traits.traits) { if (trait instanceof TraitMethodGetterSetter) { - multinameToMethodTrait.put(trait.name_index, (TraitMethodGetterSetter) trait); + Multiname m = abc.constants.getMultiname(trait.name_index); + multinameToMethodTrait.put(abc.constants.getMultiname(trait.name_index), (TraitMethodGetterSetter) trait); } } for (int frame : frameToTraitMultiname.keySet()) { - int multiName = frameToTraitMultiname.get(frame); + Multiname multiName = frameToTraitMultiname.get(frame); if (multinameToMethodTrait.containsKey(multiName)) { TraitMethodGetterSetter methodTrait = multinameToMethodTrait.get(multiName); int methodIndex = methodTrait.method_info; @@ -2722,6 +2728,10 @@ public class XFLConverter { if (!script.isEmpty()) { script = "#initclip\r\n" + script + "#endinitclip\r\n"; } + + if (spriteId == 320) { + System.err.println("xxx"); + } Map frameToScriptMap = new HashMap<>();