Skip to content

Export and import scripts / Hm05Script

Hm05Script ​

hm05 export / import scripts — types for VS Code autocompletion.

Put this file next to your script and start the script with /// <reference path="./hm05-script.d.ts" /> //

Ts-check ​

A script is one .js file (ES module).

EXPORT scripts (hm05.defineExporter) are loaded in Export → Format → "Script…". They run in a sandbox (a Web Worker): they get a READ-ONLY copy of the open document, cannot change the file and write their output through api.output. The editor puts the files in a ZIP (one file = that file alone) and downloads it.

IMPORT scripts (hm05.defineImporter, File → Import → "Import with Script…") read a file the user picks (and files next to it) and BUILD Library items — pictures, symbols with layers / keyframes, marker types and markers — through api.build. Nothing changes until the script ends; then everything it built goes in as ONE undo step.

Network: off unless the user ticks "Allow internet access" for the script (default off) — fetch is then available.

Units: positions / sizes are document units (stage pixels at 100%); pictures from api.render are output pixels (units × scale). Angles are DEGREES, clockwise (y points down, like the stage). Frames are 0-based (the timeline shows frame 1 for frame 0).

Interfaces ​

InterfaceDescription
Api-
BooleanField-
Bounds-
ColorField"#rrggbb"
ExporterDefinition-
ExportSettingsThe Export dialog's own fields (the ones above the script options).
FieldBase-
Filter-
FrameInfoOne frame of the export (the dialog's timeline, scenes and range).
FrameQueryWhich timeline to look at. Default: the Export dialog's "Timeline".
Global-
ImageSpec-
ImportApi-
ImporterDefinition-
KeySpec-
LayerChoice-
LayerInfo-
LayerSpec-
LayerStateA layer at one frame.
MarkerInfoOne marker (an instance of a component) at a frame. Markers are never drawn by any export — they are data for scripts. geometry is as stored, in its layer's space; matrix maps that space to the timeline you asked about (inside a symbol instance: its place on that timeline), and the other fields are already in timeline space.
MarkerSpecA marker on a key of a marker layer (geometry in the layer's units; values by field key — missing ones keep the field default).
MarkerTypeInfoA marker type defined in the Markers panel (e.g. "itr").
MarkerTypeSpecA marker type an import needs. If the document (or this import) already has a type of that NAME it is used as it is — this spec is skipped — so importing several files of one game defines them once.
NumberField-
ObjectInfoOne object at a frame (tweens, motion guides, layer moves applied). "Timeline space" = the coordinates of the timeline you asked about (the stage for the main timeline, the symbol's own space for a symbol).
PackOptions-
PackResult-
ParabolaInfoA parabola type's physics: x(t) = x + vx·t, y(t) = y + vy·t + g·t(t−1)/2 per whole frame (game physics: move, then vy += g), or y + vy·t + g·t²/2 when continuous.
Point-
RenderFrameOptionsWhich timeline to look at. Default: the Export dialog's "Timeline".
RenderObjectOptions-
ScriptImageA picture made by api.render.
SelectField-
Stage-
StringField-
SymbolFielda Library symbol (value = its id; "" = the main timeline)
SymbolInfo-
SymbolSpec-
TargetWhich timeline to look at. Default: the Export dialog's "Timeline".
TimelineInfo-
TransformA matrix taken apart the way Flash's Transform panel shows it.

Type Aliases ​

Type AliasDescription
BlendMode-
ElementSpecAn object on a key of a vector layer. Position / scale / rotation (degrees) place it; for a picture (x, y) is its top-left.
FilterType-
MarkerShapepolygon = closed straight edges: corners of its own per marker + an optional centre (the pivot a game scales it about)
MarkerValue-
Mat2D affine matrix [a, b, c, d, tx, ty]: a point maps to (a·x + c·y + tx, b·x + d·y + ty) — the layout of pixi / canvas setTransform(a, b, c, d, tx, ty).
ObjectType-
OptionField-
OutputData-

HereSplash — 2D animation for the web