JPEXS Free Flash Decompiler Issue Tracker

If you are looking for the decompiler itself, visit

: The issue tracker is now writable again and logged users can download files too. But note that our support is very LIMITED.

List of issuesList of issues

#774 Single file Action Script export
Date created:
Type: question
Visibility: Everybody
Assigned to:
Labels: AS1/2AS3Commandline
State: closed Help

Hi everyone, and thanks in advance for your time. I have a question, which could be turned into a feature request if the devs are willing to add any parameter to make this use case possible/easier. My objective is to get all the code/logic of a game to read some formulas/data. In case it is of any use, the game is "Anti-Idle: The Game" and the dev allows the players to decompile it for this purpose. The game is currently developed and maintained, so I have multiple versions of it. I've been using Flare to decompile it, which output a diff-friendly single file (always preserve the same order for code/objects) BUT some times fails to decompile, while JPEXS decompile correctly. So, I tried to generate something similar with JPEXS: 1. I exported the AS scripts using command-line parameters like 'ffdec.jar -export script "C:\decompiled_AITG" AITG.swf' 2. Made a python script to join all the code in a single file, sorting by the IDs generated in the folders/files. But I noticed the following: * The objects IDs (numbers in folders) seem maintain some kind of order and they seem to generate a diff-friendly output when order of IDs is maintained * but IDs in the filenames (events?) generated for different versions, get a completely different order (not diff-friendly), even when no changes were made to their AS scripts So, any idea if is possible to generate a diff-friendly single AS file export with JPEXS? In case you wanna see what I mean, I'll add 2 versions of the game, thier SWFs, output with Flare and JPEXS for comparisons... Game SWFs: ATG_-_Reconstruction.v1696.swf ATG_-_Reconstruction.v1697.swf decompiled with Flare: flare_export_v1696_noids.txt flare_export_v1697_noids.txt decompiled with JPEXS: jpexs_export_v1696.txt jpexs_export_v1697.txt If you diff the files decompiled with Flare, you'll notice that the code didn't change much, but I can't get a meaningful diff out of JPEXS output because the code is unsorted between versions. Although, notice that some objects with a single Event/file is diff-friendly. I hope I made myself clear, I know this may be a weird question / feature request, but I'll be thankful for any advice/help. Laters.
Sorry I just realized I generated "jpexs_export_v1697.txt" incorrectly. Please, use "jpexs_export_v1697_correct.txt" instead of that one.
Please try the latest nightly version. then in advanced settings/Export uncheck the incluse character id in export file name setting. Now i have only the real diffrences. Is it ok for you?
State: new→upgraded
Ok, I've been doing some tests and this is what I found: * Using command-line (like I said I was using in the main report): Either checking or unchecking the new setting is NOT getting me a diff-friendly output. In fact, and this probably deserve a new bug report, ***but I'm getting more AS files from command-line export than UI export!!!*** * Using UI (selecting "scripts" and exporting selection): Either checking or unchecking the new setting is getting me a diff-friendly output (like you tested I guess) ***BUT I'm missing some AS files!!!*** :'( You can try it yourself, I've reproduced the 2 different export like this: Commandline: ffdec_4.0.5_nightly366\ffdec.bat -export script export_cmd366_1696 ATG_-_Reconstruction.v1696.swf >nul UI: selected "scripts" folder and clicked "export selection" For me, command-line export has an output of 5962 files, 993 folders and UI export an output of 5035 files, 532 folders. Comparing the outputs I found out that most (if not all) "DoAction" of "DefineSprite" were missing from UI export (see in the attached image how the "export" option is greyed out for the selected item, although It did get exported from CMD) I'm getting the following in stderr, but I'm getting the same errors both in CMD and UI, so I guess that's not the reason of the missing objects: Jan 21, 2015 2:01:27 AM com.jpexs.decompiler.flash.action.ActionGraphSource adr2pos SEVERE: Address loc12518 not found Jan 21, 2015 2:01:27 AM com.jpexs.decompiler.flash.action.swf4.ActionIf getBranches SEVERE: Invalid IF jump to ofs12518 Jan 21, 2015 2:01:27 AM com.jpexs.decompiler.flash.action.ActionGraphSource adr2pos SEVERE: Address loc12518 not found Jan 21, 2015 2:01:27 AM com.jpexs.decompiler.flash.action.swf4.ActionIf getBranches SEVERE: Invalid IF jump to ofs12518
more AS files from command-line export than UI export: fixed now the UI ans command line exports exaclty the same files. Please try it. SEVERE: Address loc12518 not found (+ other 3) is a decompilation problem. Please create new issue if you want them to be fixed. JPEXS will fix them later.
The commandline/UI fix is great, now I'm getting the same results from both methods. As for the "diff friendly" output, it's almost there, this is what I've seen so far: * Removing IDs does generate a perfect diff, but the lost of IDs is a big deal for me, since all I can't tell easily which parts are related to each other. * Not removing IDs, generates a quite "diff friendly" output already, but like I said before, some objects get reordered and screw the diffs. It needs some tweaking. Since I had some free time (and I didn't want to bother you more than I already did :P), I decided to see code if I could come out with a solution (quite bold on my part :P as I'm not a Java dev and my knowledge about Flash internals is almost non-existant :P). But I think I found something that may be useful: Looking exported AS files and the objects in the tree generated by the FFdec GUI for the 'ATG_-_Reconstruction.v1697.swf' file, I noticed the following: * the unordered objects were coming from objects with same IDs. (look at "multiplesAS_sameIDs.png") * when exporting these files, the code add a secuential number at the end of the filename to differentiate them (like "on(release)"), first come first served, so I guess this is what is scrambling the objects (see "code_that_adds_secuential_IDs.png") * all the objects that are sharing IDs and generating a non-friendly diff output are "PlaceObjects" * all PlaceObjects with the same IDs, have different "Depth" (look at "PlaceObject2_depth.png", for those particular objects, the depths are 7, 12 and 17) After a while I got curious about this depth attribute (I guess you or jpexs probably already know about it, but I didn't), In this page: it says: "The depth value determines the stacking order of the character. Characters with lower depth values are displayed underneath characters with higher depth values. A depth value of 1 means the character is displayed at the bottom of the stack. There can be only one character at any given depth. This means a character that is already on the display list can be identified by its depth alone. (i.e. a CharacterId is not required)." So I guess it would help to generate a sortable Unique ID between the different instances of these PlaceObjects. So I added 3 lines of code in CharacterIdTag.getExportFileName() (see "code_changed.png") to generate directories like "PlaceObject_ID_DEPTH" instead of just "PlaceObject_ID", and after sorting the code by object types + IDs (which I get from the file structure), now I'm getting diff like I wanted (showing only the real changes). Doing a diff of "export_modified_ffdec_1696.txt" "export_modified_ffdec_1697.txt" (which are just a concatenation of the exported files, sorted by name + ID), both generated by the modified version of ffdec, show only the real changes. It "works for me"(TM) and "at least for this case"(TM), but I guess you are savvy enough to check if this is a good idea/valid solution and implement it correctly if necessary. Quite a long comment, it's 1AM and I'm sleepy, English isn't my native language, so I'm praying I made myself clear :P
Ok, It is a good idea. I added the depth to the export file name (and to the tree nodes in the GUI, too) And removed the "Removing IDs" setting, because it was only added for you, and you don't need it anymore. I hope you don't mind. Please try the latest nightly
I tested it with multiple versions game and it's working great. You can close this. Thanks for your help.
State: upgraded→closed