Runtime SWF Injection Demos

Exploring how runtime APIs can be written in ActionScript and injected into recompiled SWFs

Back to SWFRecomp

These demos explore LittleCube's proposal: implement the AS2 runtime through actual ActionScript code, build a "runtime" SWF from it, and recompile it alongside the game SWF. Multiple approaches are compared, plus a graphics demo showing display list inspection.

Demos

Demo 1: loadMovie Inspection

ActionScript loadMovie

A parent SWF loads a child via loadMovie(), then enumerates everything visible: timeline variables, functions, _global contributions, prototype modifications, and MC properties. Shows that ActionScript has full unified visibility into loaded content.

Run Demo

Demo 3: C Code Injection

C test_harness runtime internals

A C test_harness.c walks runtime internals after a child SWF loads: MovieClip structs, _global object, variable array, display list, and dictionary. Reveals that C code sees raw structs but misses the integrated AS variable scope.

Run Demo

Demo 4: Prelude SWF

Prelude LittleCube's idea

A "prelude" SWF runs before the main SWF, sharing the same _global, variable scope, and prototype chains. It sets up _global.runtimeVersion, MovieClip.prototype.greet, and a Greeter constructor with prototype methods — all immediately available to the main SWF.

Run Demo

Display Editor (Graphics)

WebGPU C test_harness

Three colored rectangles rendered via WebGPU. A C test harness dumps the display list after the first frame, showing each shape's depth, position, scale, rotation, and character type. Foundation for live display list editing.

Run Demo

Ruffle Display Editor

Ruffle ExternalInterface

Same concept as the Display Editor, but running in Ruffle instead of SWFRecomp. An AS2 wrapper SWF creates colored boxes and exposes its display list via ExternalInterface. JavaScript reads and writes MovieClip properties through the bridge.

Run Demo

Ruffle Display Editor (Inject)

Ruffle Bytecode Injection

Injects ExternalInterface bridge bytecode directly into a dropped SWF before loading it in Ruffle. No wrapper SWF needed — the bridge runs inside the target SWF with direct access to _root. AS2 only.

Run Demo

Comparison

Capability Demo 1 (AS) Demo 3 (C) Demo 4 (Prelude)
Timeline variables Full access Not accessible Shared scope
_global contributions Visible Not visible Shared _global
Prototype modifications Visible Walk manually Shared prototypes
Custom constructors N/A N/A Full OOP
Timing Deferred After-tick hook Before frame 1

Conclusion

Demo 4 (Prelude SWF) validates LittleCube's proposal. Runtime API implementations written in ActionScript, compiled into a prelude SWF, and statically linked with the game SWF provide full scope sharing and immediate availability. Contributors can write AS2 instead of C for the runtime API surface.