Communitygithub.com

animate-jsfl-rebuild

Rebuild legacy Flash/SWF/FLA animation projects (old tutorials, .swf references, teaching asset packs, Chinese calligraphy demos) as editable Adobe Animate 2024 documents via JSFL automation. Use when asked to recreate or port an old Flash animation automatically, decompile a reference SWF with FFDec/XFL, script Animate layers/tweens/masks/sound/AS3, bake reference animations into sprite sheets, or package a relocatable human-runnable generator that outputs a finished .fla/.swf.

What is animate-jsfl-rebuild?

animate-jsfl-rebuild is a Claude Code agent skill that rebuild legacy Flash/SWF/FLA animation projects (old tutorials, .swf references, teaching asset packs, Chinese calligraphy demos) as editable Adobe Animate 2024 documents via JSFL automation. Use when asked to recreate or port an old Flash animation automatically, decompile a reference SWF with FFDec/XFL, script Animate layers/tweens/masks/sound/AS3, bake reference animations into sprite sheets, or package a relocatable human-runnable generator that outputs a finished .fla/.swf.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/a19353433291/animate-jsfl-rebuild/tree/HEAD

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Animate JSFL Rebuild

Overview

End-to-end workflow for reconstructing a legacy Flash animation inside Adobe Animate 2024 from (a) a tutorial/lesson document plus source assets and (b) a compiled reference SWF. The deliverable is a JSFL generator that produces a finished .fla, plus a self-contained package a non-technical recipient can run in Animate with no Python/tooling.

Always prefer measured facts from the reference SWF over assumptions. Every JSFL behavior below was empirically verified on Animate 2024 (WIN 24,0,11,4); re-probe when the version differs.

Workflow

Phase 0 — Preflight (5 min)

  1. Verify Animate CLI works: "<Animate dir>/Animate.exe" "<script>.jsfl" -AlwaysRunJSFL.
  2. Check python + Pillow (set PYTHONPATH to the machine's site-packages when sys.prefix misresolves), Java/FFDec, a headless rasterizer (resvg).
  3. Read scripts/jsfl_probe.jsfl, run it once in Animate, and read the generated probe log. It confirms document type, frame semantics, layer/folder behavior, symbol creation and export in the current build.

Phase 1 — Recon and extraction

  1. Parse the reference SWF header (stage, fps, frame count) before anything else — it is the acceptance baseline. Use scripts/validate_swf.py --swf <ref.swf> --header-only.
  2. Export the reference to XFL with FFDec: java -jar ffdec.jar -export xfl <outdir> <ref.swf>. The XFL DOMDocument.xml + LIBRARY/Symbol *.xml give authoritative layer structure, keyframes, matrices, alphas, blend modes, filters, frame scripts and sound names.
  3. Do not use -export sprite for artwork: it renders sprites as white outlines on black. Use XFL shape XML (edge strings) or FFDec -export shape -format shape:svg, or render main-timeline frame exports as visual ground truth.
  4. Mine the tutorial document only for names, techniques and numbers the SWF cannot express; reconcile conflicting numbers in favour of the SWF when validating visually.
  5. Inventory source assets with Pillow (dimensions/alpha). Identify which library symbols wrap which bitmaps.

Phase 2 — Choose the reconstruction strategy

Read references/reconstruction-strategies.md for the full decision matrix. Short version:

  • Scriptable as-is: stage properties, layers/folders, bitmap imports, symbol instances, classic motion/shape tweens, alpha/advanced color, blend modes, sound-on-frame, frame stop().
  • Not scriptable (plan a workaround up front):
    • Eraser-based stroke isolation and hand-drawn shape tweens → bake per-frame sequences from the reference geometry or frames.
    • Element filters (blur/glow) → pre-bake blurred PNGs with Pillow.
    • SVG import → always opens a modal dialog; rasterize at 4× instead.
    • Animated GIF import → frame content silently comes out transparent (palette/transparency handling); do not rely on it.
    • Layer masks → only dependable as one isolated mask/child pair; set layerType="mask" before adding any content, associate child via parentLayer, and wrap every pair in its own symbol.
  • Most robust fallback for reveal/writing animations: sprite sheet + per-frame AS3 offsets — one bitmap placement per sequence, then per-frame s.x/s.y scripts. See the strategy reference for grid math.

Phase 3 — Build the JSFL generator

Follow references/jsfl-api-notes.md. Architecture that scales:

  1. Config block: resolve paths from fl.scriptURI (format file:///C|/... → normalize), never hardcode user directories.
  2. L()/T() logging helpers writing to a file via FLfile.write(..., true) (append) — one line per step; never rely on traces.
  3. Helpers: findLayerLast, ensureKey (select layer+frame first), placeItem with 1–4 retries, copy-keyframe mode for repeated keys, artSym, sheetAnimMC, folder/mask recipes, library-name normalization.
  4. Build order: import assets → build symbols (bitmaps → composite MCs → animation MCs) → create main scene skeleton (folders/children) → fill layer contents → set folder/mask/guide relations → sound/AS → save.
  5. Prefer one addItemToDocument per layer (or per sequence) and insertKeyframe copies afterwards; each placement can trigger a blocking modal on some installs.

Phase 4 — Run and debug loop

  1. Run headless-ish via CLI; watch the log file, not the GUI.
  2. If blocked, use scripts/animate_dialog_helper.ps1 (dev-only): brings any Animate dialog topmost/foreground and presses Enter. Never ship it.
  3. Keep scripts off long busy loops; Animate's watchdog asks "script running a long time — continue?" and interrupts publish.
  4. Publish is asynchronous: closing the doc/fl.quit() right after publish() leaves a truncated SWF (~50 bytes). Reopen the saved FLA, publish, then keep the app open and poll file size; for recipients, document Shift+F12 instead.

Phase 5 — Verify and package

  1. Structural check: unzip the .fla (XFL zip), assert layer count, frame counts of animation symbols, frame ActionScript, soundName on the music layer.
  2. Visual check: render key frames from the produced SWF and the reference with FFDec -export frame; compare side-by-side with Pillow (scripts/validate_swf.py supports both).
  3. Accept only when stage/fps/frames match and reveal/timing motions match the reference frames you sampled.
  4. Handoff package per references/handoff-package.md: source/ assets/ data/ <script>.jsfl README.md <prebuilt>.fla, relocatable, no dev helpers/logs, human runs it from the Scripts menu and clicks dialogs.

Critical rules (hard-won)

  • Frame APIs are 0-based: insertKeyframe(n), setSelectedFrames(n,n), frames[n].startFrame.
  • timeline.currentFrame readback is unreliable; always setSelectedLayers + setSelectedFrames.
  • Select the target layer and frame before insertBlankKeyframe/draw operations; stale selection silently puts content on the wrong layer.
  • Animate sanitizes - → _ (and sometimes . → _) in layer and symbol names; resolve library items by normalized name (replace(/[-_.]/g,"")).
  • Mask type must be set immediately after creating the mask layer, before content; mask layers clip everything below them — isolate pairs in their own symbols.
  • Folder children: select the folder, addNewLayer(name,"normal",false); create bottom→top order reversed; set parentLayer explicitly.
  • importFile requires a file:/// URI with percent-encoded non-ASCII; plain C:/... paths fail with "invalid URI".
  • addItemToDocument for symbol instances uses the registration point as the placement point; raw bitmaps use their center until x/y are assigned.
  • A corrupt/truncated SWF after publish means the script ended/quitted before the async publish finished — reopen + publish + poll, or hand off manual publish.

Resources

  • references/jsfl-api-notes.md — verified JSFL object/property behavior and ready-to-use helper recipes.
  • references/reconstruction-strategies.md — decision matrix, XFL edge-string grammar, mask/filter/eraser workarounds, sprite-sheet + AS3 pipeline math, coordinate reconciliation.
  • references/verification.md — SWF header parsing, FFDec frame rendering, PIL comparison, XFL structural assertions, acceptance checklist.
  • references/handoff-package.md — relocatable script header, package layout, recipient README template, publish caveats.
  • scripts/jsfl_probe.jsfl — dependency-free capability probe; writes a log beside itself and quits.
  • scripts/animate_dialog_helper.ps1 — dev-only watchdog/dialog helper (-Seconds N to self-terminate); never ship.
  • scripts/validate_swf.py — header check plus optional reference-vs-generated frame comparison.

Related Skills