ShockwaveFlash.Avm1
1.1.0
See the version list below for details.
dotnet add package ShockwaveFlash.Avm1 --version 1.1.0
NuGet\Install-Package ShockwaveFlash.Avm1 -Version 1.1.0
<PackageReference Include="ShockwaveFlash.Avm1" Version="1.1.0" />
<PackageVersion Include="ShockwaveFlash.Avm1" Version="1.1.0" />
<PackageReference Include="ShockwaveFlash.Avm1" />
paket add ShockwaveFlash.Avm1 --version 1.1.0
#r "nuget: ShockwaveFlash.Avm1, 1.1.0"
#:package ShockwaveFlash.Avm1@1.1.0
#addin nuget:?package=ShockwaveFlash.Avm1&version=1.1.0
#tool nuget:?package=ShockwaveFlash.Avm1&version=1.1.0
ShockwaveFlash.Avm1
AVM1 (ActionScript 1/2 bytecode) support for ShockwaveFlash — decode DoAction bytecode to a typed action model, evaluate data scripts to a typed value tree, edit, and write the bytecode back.
Install
dotnet add package ShockwaveFlash.Avm1
Read a data table
Linear data scripts (localization / config tables, common in older games) are replayed to their global variables:
using ShockwaveFlash;
using ShockwaveFlash.Avm1;
using ShockwaveFlash.Tags.Action;
var swf = ShockwaveFlashFile.Disassemble(File.ReadAllBytes("emotes.swf"));
var version = swf.Header.Version;
var tag = swf.Tags.OfType<DoActionTag>().First();
Avm1Object globals = tag.Evaluate(version);
string name = globals["EM"].AsObject["1"].AsObject["n"].AsString;
Edit & write back
Avm1Object / Avm1Array are editable in place, and primitives convert implicitly:
var globals = tag.Evaluate(version);
var emotes = globals["EM"].AsObject;
emotes["1"].AsObject["n"] = "New name"; // change
emotes["24"] = new Avm1Object { Members = { ["n"] = "New emote", ["s"] = "new" } }; // add
var output = swf.ReplaceTag(tag, tag.WithGlobals(globals, version)).Assemble();
File.WriteAllBytes("emotes.swf", output.ToArray());
Raw actions
For surgical edits that preserve everything else byte-for-byte, go through the action list instead of the value tree:
var actions = tag.DecodeActions(version); // IReadOnlyList<Action>
// ... inspect or modify actions ...
var newTag = tag.WithActions(actions, version); // re-encoded; byte-identical when unchanged
Value model
Evaluate returns an Avm1Object whose members are Avm1Values — Avm1String, Avm1Number, Avm1Boolean, Avm1Null, Avm1Undefined, Avm1Object, Avm1Array. Read them with AsObject / AsArray / AsString / AsNumber / AsBoolean.
Notes
- The decoder and encoder cover the documented AVM1 opcode set (SWF 1–7) and round-trip byte-for-byte.
Avm1Machineis a focused evaluator for linear data scripts — no control-flow or function execution. Opcodes outside the supported subset are collected inUnsupportedOpcodes; passstrict: trueto throwAvm1UnsupportedActionExceptioninstead of skipping them.
Part of the ShockwaveFlash project · MIT © Aerafal
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- ShockwaveFlash (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.