Search code examples
actionscriptnullflashswf-decompiler

Sothink SWF Decompiler using null in strange places


I've been attempting to figure out the background math in a Flash game by using the Sothink SWF Decompiler to view the ActionScript files. Admittedly I know very little about ActionScript, but I'm seeing lines of code that look like:

_loc_2 = null * (null * true) <= null;

or:

_loc_3 = null & null << (null === false);

From where I stand, value <= null doesn't make much sense, and neither does null * true or null & null. Am I just not understanding ActionScript properly, or is this an error in the decompiling process? If it's an error, is there any way to solve it?


Solution

  • The swf has probably been encrypted with an obfuscater, which is why you're seeing nonsense like this. You can test this code yourself (though you have to compile in non-strict mode):

    trace( "null & null: " + ( null & null ) ); // traces 0
    trace( "null === false: " + ( null === false ) ); // traces false
    trace( "null & null << (null === false): " + (null & null << (null === false)) ); // traces 0
    trace( "null * true: " + ( null * true ) ); // traces 0
    trace( "null * null * true " + ( null * ( null * true ) ) ); // traces 0
    trace( "null * (null * true) <= null: " + (null * (null * true) <= null) ); // traces true
    

    so basically _loc_2 is a local variable set to 0, while _loc_3 is a local variable set to true