Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.
/ python-as3 Public archive

Adobe ActionScript 3 interpreter in Python (incomplete)

License

Notifications You must be signed in to change notification settings

eigenein/python-as3

Repository files navigation

⚡ Pulse

Build status GitHub tag GitHub license Say Thanks!

Why?

I needed to run some code from a Flash-based game decompiled by amazing JPEXS Flash Decompiler.

Disclaimer

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.

Development

  • Pipfile is here to set up a development environment quickly.
  • Use isort to sort imports.
  • Run tests with pytest.

Recipes

Interactive shell

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

Running a script

from as3 import execute_script

execute_script('''
    function bar() {
        return 42
    }

    trace(bar());
''', '<ast>')

Magic functions

$ as3 --shell
Welcome to as3 shell!
Try: baz()
>>> trace(__globals__().keys())
dict_keys(['__dir__', '__globals__', '__resolve__', 'int', 'Math', 'String', 'trace', 'undefined', 'ASAny', 'ASObject', '__builtins__'])