I needed to run some code from a Flash-based game decompiled by amazing JPEXS Flash Decompiler.
The implementation may not strictly follow the ActionScript specification.
Though, you're welcome to make a pull request to improve it. Please, try to follow the code style, run isort
and add unit tests where applicable.
Pipfile
is here to set up a development environment quickly.- Use
isort
to sort imports. - Run tests with
pytest
.
The package contains an interactive shell to play around with the interpreter:
$ as3 --shell
Welcome to as3 shell!
Try: class X { function X() { this.a = 42 } function baz() { return this.a; } }; a = X().baz()
>>> class X { function X() { this.a = 42 } function bar() { return this.a } }
>>> x = X()
>>> trace(x)
<X object at 0x10bbdad68>
>>> trace(x.bar())
42
from as3 import execute_script
execute_script('''
function bar() {
return 42
}
trace(bar());
''', '<ast>')
$ as3 --shell
Welcome to as3 shell!
Try: baz()
>>> trace(__globals__().keys())
dict_keys(['__dir__', '__globals__', '__resolve__', 'int', 'Math', 'String', 'trace', 'undefined', 'ASAny', 'ASObject', '__builtins__'])