-
Notifications
You must be signed in to change notification settings - Fork 397
Big Picture
-
AVM2: is an implementation of the ActionScript3 virtual machine. All of the code for AVM2 is in
src/avm2
and only has a dependency on the top levelsrc
directory for utilities and options. -
AS3 Builtin APIs: AS3 bootstraps some of its native objects like
Array
,Object
etc. The source code for these is inavm2/generated/builtin/*.as
. These get compiled toavm2/generated/builtin/builtin.abc
(3) which is the firstabc
file that is executed by Shumway at startup. If you make changes to these files you'll need to rebuild thebuiltin.abc
file using the./generate.py
command in thegenerated
directory. -
The AS3 Builtin APIs are for the most part marked as
native
which means their implementation is implemented natively in "JavaScript". Most of this implementation is inavm2/native.ts
andavm2/natives/*.ts
. -
.swf
files (5) are parsed intoabc
blocks (7) and swftags
(8).abc
blocks contain AS3 bytecode are executed by AVM2 (1). During execution, references toflash
classes such asflash.display.DisplayObject
are detected by AVM2's linker (12) and trigger class loading. The linker knows thatflash.display.DisplayObject
is defined somewhere inplayerGlobals.abc
(10) and directs AVM2 to load it. The sources for the player globals (10) are available insrc/flash/*.as
. The vast majority of player global classes are implemented natively in JavaScript in the same directorysrc/flash/*.ts
(11). -
Most of the code that deals with Flash APIs is here. If you're looking for something to do here is a great place to start. Simply look for
notImplemented
function calls and implement them. -
Most of the Shumway subsystems are designed to work independently. The Player is a place where they are all brought together. This is responsible for loading
.swf
and processing events and communicating with the rendering engine. -
Shumway can be used from JavaScript directly, not only through ActionScript3. This makes it easy to write unit tests and even new content that relies on the well known and understood Flash APIs. See,
src/test/unit/*.js
-
Shumway is designed to run in a Worker thread so as not to jank the main rendering thread. This means we can't make use of any APIs that are only available on the main thread. The Remoting Player (14) that lives in the worker and the Remoting GFX (15) module communicate via post message, sending across drawing commands and user input. Most of the remoting code is in
src/player
. -
Flash uses a retained mode drawing API which manages a display list (a tree of DisplayObjects and DisplayObjectContainers). This display list is synchronized with a Frame Tree (17) that lives on the main thread. The GFX backend (18)
src/gfx
is responsible for drawing the frame tree whenever it changes. There are currently two rendering backends: a WebGL backend (19) and a Canvas2D backend (20).
Mozilla 2019