JPEXS Free Flash Decompiler Issue Tracker

If you are looking for the decompiler itself, visit https://github.com/jindrapetrik/jpexs-decompiler

NEW : We have got a new blog where we post some interesting SWF internals info.

List of issuesList of issues

#2509 AS2 direct edit doesn't recognize static class variables
Author:
Date created:
Type: bug
Visibility: Everybody
Assigned to:
State: new Help

> What steps will reproduce the problem? Make a blank AS2 .swf file, add the following class: ``` class Users { private static var numInstances:Number = 0; function Users() { numInstances++; } static function get instances():Number { return numInstances; } } ``` and a frame script with the following code after that: ``` trace(Users.instances); var user1:Users = new Users(); trace(Users.instances); var user2:Users = new Users(); trace(Users.instances); ``` > What is the expected output? What do you see instead? Firstly, the :Number after the instances() function declaration creates trouble, so it has to be removed. Secondly, instead of tracing 0, 1, 2, it traces undefined, NaN, NaN, because numInstances in the class code refers to a global variable separate from the static class variable. This can be fixed by changing "numInstances" to "Users.numInstances", but I would still like to not have to write it out every time. > What version of the product are you using? Is it "nightly build"? Which operating system do you have? I'm using v24.0.1 on Windows 11. > Please provide any additional information below. If the problem is related to a SWF file, attach it here, otherwise we can't help you. Additional notes: I think I understand why the compiler doesn't interpret the code as I want to, because on decompilation of a normally compiled .swf file it always adds the "Users." in front of static variables automatically. However, I'm currently writing a bunch of AS2 code in a separate editor and then periodically copying it over to FFDec, and as I'm using static variables inside their classes quite a lot, it would be quite convenient if I didn't have to add the class name in front every single time (also, it seems like the "import" keyword doesn't work as well). The code presented here is copied from I think official documentation (https://open-flash.github.io/mirrors/as2-language-reference/statements.html#static), so it would be nice if it worked. But I can understand if this won't be changed and FFDec will only compile scripts that are in similar form to the ones that come from its decompilation.