Format:SWF
| On this wiki | Facts · Code · Notes · Topics |
|---|
Adobe Flash movie (.swf, also AIR application content): an 8-byte header (FWS, CWS for zlib or ZWS for LZMA, then a version byte and the total uncompressed length) followed by a body of tags; AS3 code lives in DoAbc/DoAbc2 tags as ABC bytecode, AS1/2 in DoAction tags.
Header
| Offset | Size | Meaning |
|---|---|---|
| 0 | 3 | FWS uncompressed, CWS zlib body (SWF 6 and later), ZWS LZMA body (SWF 13 and later). GFX/CFX are the Scaleform variants, treated the same way
|
| 3 | 1 | SWF version (0 is rejected) |
| 4 | 4 | u32 file length of the whole uncompressed file, header included |
For CWS everything after byte 8 is one zlib stream. For ZWS bytes 8..12 are the compressed length, then the 5-byte LZMA properties and the LZMA stream, without the usual 8-byte uncompressed size (Flash's mangled LZMA header). The decompressed body starts with the stage RECT (bit-packed, in twips), an 8.8 fixed frame rate, a u16 frame count, then tags. Little endian.
Tags
Each tag starts with a u16: tag code in the upper 10 bits, length in the lower 6 bits; length 63 (0x3F) means a u32 length follows. Selected codes: 0 End, 1 ShowFrame, 9 SetBackgroundColor, 12 DoAction, 39 DefineSprite, 56 ExportAssets, 59 DoInitAction, 69 FileAttributes, 72 DoAbc, 76 SymbolClass, 77 Metadata, 82 DoAbc2, 86 DefineSceneAndFrameLabelData, 87 DefineBinaryData.
ActionScript
- DoAction (12) and DoInitAction (59) carry AVM1 bytecode for AS1/AS2.
- FileAttributes (69), a flag byte at the start of an AS3 file: bit 3 (0x08) = ActionScript 3, bit 4 = has Metadata, bit 5 = UseGPU, bit 6 = UseDirectBlit.
- DoAbc (72) is the raw Format:ABC file to the end of the tag. DoAbc2 (82) is u32 flags (bit 0 = lazy initialize), a NUL-terminated name, then the ABC file. SymbolClass (76) binds character ids to AS3 class names.
Tools
Ruffle's swf crate (reader and writer) and JPEXS Free Flash Decompiler are the open references; see linked repositories.
See also
- Library:Scaleform GFx: the GFX and CFX variants and their extra tags.
Code & repositories
- https://github.com/ruffle-rs/ruffle @
74323048b31da253175faf7ad1f3b4c8ef13fd66· license: MIT OR Apache-2.0 (declared by the contributor for the files used; GitHub reports MIT (read from LICENSE.md; GitHub's API was busy) for the repository)
Ruffle: Flash Player emulator; its swf crate is a complete SWF/AVM1/ABC reader and writer (tag codes, header decompression, ABC structures).
Tested on: source read, not run: source read only · checked 2026-10-18 - https://github.com/jindrapetrik/jpexs-decompiler @
de7efbf4754865f46c1c5bd36c9db9cc4ef2fa0b· license: GPL-3.0-or-later (declared by the contributor; GitHub's detector did not recognize a license file)
JPEXS Free Flash Decompiler (ffdec): SWF/ABC decompiler and editor in Java; ffdec_lib parses every tag and the AVM2 bytecode.
Tested on: source read, not run: source read only · checked 2026-10-18