Declarations of a SWF's classes
swf2es types movie.swf -o movie-types.ts --name Moviewrites TypeScript declarations of the classes the SWF’s ActionScript 3
defines: for each, an interface of its instances’ public members and one of
its static ones, keyed by qualified name in MovieClasses and
MovieStatics. A class extends the declarations of the one it extends in
the player’s libraries (@swf2es/player/as3-types), so a subclass of
flash.display.Sprite has Sprite’s members; a type that no library
defines is avm2.Value. --air takes AIR’s library in too. With them, a
host’s code reads a script’s objects by name, checked as it compiles:
import type { avm2 } from "@swf2es/runtime";import type { MovieClasses } from "./movie-types.js";
const hero = value as avm2.Ref<MovieClasses["game::Hero"]>;const hp = scripting.rt.prop(hero, "hp"); // a number; "hpp" would not compilescripting.rt.callProp(hero, "attack", null, 2);