Time Rift Time Rift - 10 months ago 94
ActionScript Question

Determining ActionScript version based on results of a flash decompiler

I need to determine the ActionScript Version of a SWF file from within an application without using another SWF to get the information, and as I was doing research for this, I came across this flash decompiler.

I used this tool to decompile several flash files that I already knew that ActionScript version of, and I noticed a difference between the ActionScript 2 files and ActionScript 3. In this screenshot:(unfortunately I cannot post images yet), you can see that the the bottom SWF called

Cardio Sequence.swf
, which is an ActionScript 3 file, has a file in the
folder called

In all the files that I tested, the ActionScript 3 files had this
file, whereas the ActionScript 2 ones did not. Is there any way that I can get this information to be readable as a string inside of another application (i. e.
if (scripttext.MainTimeline != null) {doSomething}
)? Or is this even a feasible way of determining the ActionScript version?

Answer Source

The FileAttributes tag in the SWF file contains a flag that indicates whether the SWF uses AVM1 (ActionScript 1.0/2.0) or AVM2 (ActionScript 3.0). If this tag is omitted, the SWF is for Flash Player 7 or earlier and can only be AVM1. More info is in the SWF specs.

You can use any SWF parsing library or decompiler of your choice to look for this tag. The particular JPEXS decompiler supports command line options to output a list of SWF tags, AS2, and/or AS3 scripts to a file. This includes the -dumpSWF, -dumpAS2, and -dumpAS3 command line arguments. For example:

ffdec.bat -dumpSWF myfile.swf