Skip to main content

Python implementation of ActionScript3

Project description

python-as3lib

A partial implementation of ActionScript3 and flash in python. Things are as close as I could get them with my knowledge and the very limited documentation that adobe provides. Once I learn how to make python c modules, I plan on offloading some of this stuff to c or c++ modules to speed things up. If I can figure out how to do it in this context, I might implement the interface in OpenGL, Vulkan, or something like PyGame to make it work better and more customizable. Some stuff will be impossible to implement in python because python is a fish.

Version 0.0.8 note: I have currently implemented basic dependency checks. They aren't very good and might fail. If you have problems with them, remove the line in initconfig.py that calls the function "dependencyCheck" or change the variable "checkdependencies" in configmodule.py to False.

Warning: Some early versions of this library that contain the config module are broken on Windows. It was fixed in version 0.0.6.

If you are using wayland, this library will have a first time init message because wayland does not currently support fetching some values automatically. You must either launch this library, or the program that uses it, from the terminal to input these values, or fill out the blank config file that I provide on github (it will lock up otherwise). These values are stored in <library-directory>/wayland.cfg. They are only needed if you are using any of the graphical elements of this library. I will not be able to fix the window grouping jank on wayland until tcl/tk natively supports wayland.

I have no way as of current to test the accuracy of these functions as I can't find a compiler for actionscript that I could get to work so if anything doesn't work or there is undocumented functionality please let me know on the github issues page. DO NOT EMAIL ME, I will not respond and nothing will get fixed.

Requirements

System:
 Linux:
  bash (will add support for others later)
  xwininfo (xorg)
  xrandr (xorg)
  echo
  grep
  awk
  loginctl (This requirement will probably be removed later, this was just the easiest way to do things)
  whoami
 Windows:
  PyLaucher (should be included in the python installer)
Python:
 Built-in:
  tkinter, re, math, io, platform, subprocess, random, time, datetime, os, pwd (linux), pathlib, configparser, webbrowser, textwrap, typing
 External:
  numpy, Pillow, tkhtmlview

Future Requirements

The requirements that are going to be needed in the future once I implement more.
Python:
lzma, zlib, gzip

Modules

There are currently 16 modules plus a parser (not even close to working yet, I also don't know how far I'll be able to go with it) in this library, toplevel, interface_tk, keyConversions, configmodule, initconfig, com.adobe, flash.ui, flash.display, flash.filesystem, flash.utils, flash.events, flash.display3D, flash.net, flash.crypto, flash.system, and flash.errors.

toplevel

Most of the functions and classes are implemented but there are some things missing. The inherited properties of many of the classes would be a pain to implement so I left them out for now.

As of version 0.0.7 I reimplemented the Array and String class as extensions of the their conterparts from python instead of how I was doing it. I also implemented creating an array to a specified size in the constructor and implemented the length assignment feature. Array.toSize has been merged into length and no longer exists. I also added the ability to specify what to fill the empty slots with when using length assignment (not in actionscript).

I implemented the type conversions inside a separate function in some of the dataclasses (ex: String._String(exression)). These are used as part of the constructor (__init__ function) but are separate in case they need to be used multiple times or by those using this library. They return values in python types instead of in the types of this module because they are meant to be used internally.

As of version 0.0.8 the length properties of various classes are properties instead of functions (as they should be). The Int class is now named properly (now named int) and the rest of the module uses builtins.int for python integers. This version also makes many functions more accurate to the original as well as making some things faster.

interface_tk

Warning: This module is does not retain compatibility between versions, things will change when I need them to with no regard to consistancy.
Unlike the other modules, this one is completely different from anything actionscript had. This module implements dynamic scaling and other things that I need for a game port that I am working on. I will try to make one with similar syntax to actionscript later (no promises). Making the windows too small will result in a divide by zero error and might cause the program to crash if not handled. This will be fixed later.

keyConversions

This module includes cross-platform key conversion functions for tkinter events, javascript (actionscript) keycodes, and mouse buttons (currently only supports united states standard keyboard on linux and windows).

configmodule

The module that holds all of the things that this library needs globally or that need to be used many times so I only have to fetch them once. This module includes information like;
the current platform
the library directory
library debug status
the config for the trace function loaded from mm.cfg
details about the screen (width, hight, refresh rate, and color depth) for the display module.
information about the filesystem (path separator, user directory, desktop directory, and documents directory) for the flash.filesystem module
library initialization status and errors

initconfig

The module that is called when this library initializes and its only purpose is to set the variables in configmodule.
Note: use of multiple displays has not been tested yet.

flash.cryto

This module is as cryptographically secure as it can be while being reasonably fast. It uses the os.urandom function. Currently its functions return python strings because I haven't implemented bytearrays yet but I plan to switch it in the future.

com.adobe, flash.ui, flash.display, flash.filesystem, flash.utils, flash.events, flash.display3D, flash.net, flash.cryto, flash.system, and flash.errors

These modules contain things from their respective actionscript modules. None of them are complete yet since many actionscript modules rely on each other to function. I have to go back and forth between modules coding things here and there so these are taking much longer than the other modules.

Config Files

<library-directory>/mm.cfg - this file is the same as it was in actionscript with the same options as defined here with the exception of "ClearLogsOnStartup" which I added to configure what it says. Its defualt value is 1 to match the behavior in actionscript.
<library-directory>/wayland.cfg - generated on the first use of this library if you are using wayland. Stores all of the values that can't be fetch automatically so you only have to input them once. They must be changed manually if you want to change them.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

as3lib-0.0.8.tar.gz (54.8 kB view hashes)

Uploaded Source

Built Distribution

as3lib-0.0.8-py3-none-any.whl (55.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page