Skip to main content

Python implementation of ActionScript3

Project description

python-as3lib

A python implementation of some of the ActionScript3 functions and classes. They are as close as I could get them with my knowledge and the very limited documentation that adobe provides.

There are currently five modules in this library, toplevel, interface_tk, keyConversions, com.adobe, and flash.ui. Toplevel is a module that contains top level functions from actionscript. Interface_tk is a module that tries to get a usable interface that functions similar to actionscript. KeyConversions is a module for cross-platform key conversions and recognition. com.adobe is the classes from the origional com.adobe. flash.ui is the classes from the origional flash.ui.

Requirements

tkinter (Built-in)
re (Built-in)
math (Built-in)
io (Built-in)
platform (Built-in)
subprocess (Built-in)
random (Built-in)
time (Built-in)
datetime (Built-in)
os (Built-in)
pwd (Built-in)
pathlib (Built-in)
configparser (Built-in)
webbrowser (Built-in)
textwrap (Built-in)
numpy
Pillow
tkhtmlview

toplevel

The types (Array, Boolean, Int, Number, and String) are actual types so you can use them as such. They include almost everything that they did in ActionScript3. The length method in each type can only be used to get the length, I didn't implement the length assignment for Arrays.

Most of the inherited properties would be too hard to implement so I didn't bother with them.

I implemented the type conversion functions inside the types themselves (ex: instead of String(expression) use String.String(expression)).

For functions that needed a placeholder value for input(s) that aren't easily definable, like multiple possible types or they relied on other factors to be set, I use an empty dictionary as a placeholder. The values that these empty dictionaries represent aren't actually dictionaries, I just used something that would never be used in these functions so that I could detect it.

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 page.

interface_tk

Unlike the toplevel module, this one has completely different syntax than actionscript had. This module implements dynamic scaling and other things like the adobe flash projector. I will try to make one with similar syntax to actionscript later (no promises).

keyConversions

This module is a module that includes cross-platform key conversion functions for tkinter events, javascript (actionscript) keycodes, and mouse buttons.

com.adobe

This module contains the things from the origional com.adobe module. There wasn't much in this module but it's here.

flash.ui

This module contains the things from the origional flash.ui module. Currently only the context menu.

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.

Currently Implemented

toplevel

ArgumentError(Error Class)
Array(Function) - Moved to Array.Array()
Array(Data Type)
 Array(Constructor) - Create from values moved to class init function, create to size moved to toSize(Function).
 length(Property) - Moved to length(Function).
 concat(Function)
 every(Function)
 filter(Function)
 forEach(Function)
 indexOf(Function)
 insertAt(Function)
 join(Function)
 lastIndexOf(Function)
 map(Function)
 pop(Function)
 push(Function)
 removeAt(Function)
 reverse(Function)
 shift(Function)
 slice(Function)
 some(Function)
 splice(Function)
 toLocaleString(Function)
 toString(Function)
 unshift(Function)
Boolean(Function) - Moved to Boolean.Boolean()
Boolean(Data Type) - Data representation changed from "true" and "false" to "True" and "False"
 Boolean(Constructor) - Moved to class init function
 toString(Function)
 valueOf(Function)
DefinitionError(Error Class)
Error(Error Class)
EvalError(Error Class)
int(Data Type) - Moved to Int
 toExponential(Function)
 toFixed(Function)
isFinite(Function)
isNaN(Function)
valueOf(Function)

Math(Class) - All functions in this class had corresponding functions in python
 E(Constant)
 LN10(Constant)
 LN2(Constant)
 LOG10E(Constant)
 LOG2E(Constant)
 PI(Constant)
 SQRT1_2(Constant)
 SQRT2(Constant)
 abs(Function)
 acos(Function)
 asin(Function)
 atan(Function)
 atan2(Function)
 ceil(Function)
 cos(Function)
 exp(Function)
 floor(Function)
 log(Function)
 max(Function)
 min(Function)
 pow(Function)
 random(Function)
 round(Function)
 sin(Function)
 sqrt(Function)
 tan(Function)
Number(Function) - Moved to Number.Number()
Number(Data Type)
 Number(Constructor) - Moved to class init function
 valueOf(Function)
RangeError(Error Class)
ReferenceError(Error Class)
SecurityError(Error Class)
String(Function) - Moved to String.String()
String(Data Type)
 String(Constructor) - Moved to class init function
 length(Property) - Moved to length(Function)
 charAt(Function)
 charCodeAt(Function)
 concat(Function)
 indexOf(Function)
 lastIndexOf(Function)
 substring(Function)
 toLocaleLowerCase(Function)
 toLocaleUpperCase(Function)
 toLowerCase(Function)
 toUpperCase(Function)
 valueOf(Function)
SyntaxError(Error Class)
trace(Function) - To use trace first use the "EnableDebug" command that I added. I also changed the default file path to be flashlog.txt in the directory of this library. If you want the log file to be anywhere different, use the TraceOutputFileName definition in mm.cfg
TypeError(Error Class)
URIError(Error Class)
VerifyError(Error Class)

interface_tk

basic things to get it working but nothing substantial

Partially Implemented

toplevel

Date(Data Type)
escape(Function)
Number(Data Type)
 toString(Function)
int(Data Type)
 toString(Function) - Don't know what is supposed to happen when radix is outside of the given range (not documented)
Number(Data Type)
 toExponential(Function)
String(Data Type)
 substr(Function) - Don't know what happens when startIndex is outside of string (not documented)
unescape(Function)

Future Plans

toplevel

Array(Data Type)
 sort(Function)
 sortOn(Function)
Date(Function)
Date(Data Type)
decodeURI(Function)
decodeURIComponent(Function)
encodeURI(Function)
encodeURIComponent(Function)
int(Function)
int(Data Type)
 toPrecision(Function)
RegExp(Data Type)
Number(Data Type)
 toExponential(Function)
 toFixed(Function)
 toPrecision(Function)
 toString(Function)
parseFloat(Function)
parseInt(Function)
String(Data Type)
 localeCompare(Function)
 match(Function)
 replace(Function)
 search(Function)
 slice(Function)
 split(Function)
uint(Function)
uint(Data Type)
Vector(Function)
Vector(Data Type)

interface_tk

more types of images objects
proper canvas support

Functions I added

toplevel

listtoarray - converts a given list to an Array. Returns the Array.
Array.toSize - Creates an Array to specified size. If nothing is specified, assumes 0 elements
Dunder methods to relavent data types
defaultTraceFilePath - returns the default file path for logs
defaultTraceFilePath_Flash - returns the default file path for logs in actionscript
EnableDebug - enables "debug mode". Debug mode is something from actionscript that was enabled by using the debug version of the interpreter. Since python doesn't have a debug interpreter, this function is used to enable the debug capabilities of things in this library (only the documented ones).
DisableDebug - disables "debug mode"
formatTypeToName - takes a type object and converts it to a string without the name of the package it came from (<class 'as3.Array'> becomes "Array")
U29(class) - U29specs on page 3
 decodeU29int(Function) - decodes a u29int value from binary bits. Must have an input of either 8, 16, 24, or 32 bits as a string
 decodeU29str(Function) - decodes a u29str value

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.3.tar.gz (28.3 kB view hashes)

Uploaded Source

Built Distribution

as3lib-0.0.3-py3-none-any.whl (35.9 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