Skip to main content

Partial implementation of ActionScript3 in Python

Project description

python-as3lib

A partial implementation of ActionScript3 and adobe flash in python. This project aims to have as accurate of an implementation as possible of the stuff that I choose to implement, however, due to my limited knowledge of advanced programming and Adobe's subpar documentation, this might not be completely accurate. Some stuff will be impossible to implement in python because python is a fish.

Version 0.0.9 fixes the initconfig module so it actually works and it prints a message if there are errors while initializing. This version also includes some c modules, though they do not compile on Windows and I haven't even tried MacOS yet.

Warning: Some early versions of this library that contain the config module are very broken on Windows and can cause major issues. This 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 easily fetching some values automatically (without systemd, I do not want to depend on that). 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 only need to be accurate if you are using 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.

Requirements

System:
 Linux:
  bash (or a bash compatible shell)
  echo
  grep
  xwininfo (xorg)
  xrandr (xorg)
  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

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

Interface library for testing purposes written in tkinter. I will likely keep this around once the real interface stuff is implemented but no promises.
Warning: This is a testing library, do not expect consistancy between versions.

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). This will be moved later since flash has a place for it.

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 while it is running. 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 with the sole purpose of setting 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. This will be offloaded to a c module in the future (I have the c module made but it has a couple of problem that I have to solve before I can use it).

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 fetched automatically (without systemd) 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.9.tar.gz (58.2 kB view hashes)

Uploaded Source

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