The Contents stream is the document itself: which release saved it, the
scenes in order, the library, a record for every imported bitmap, sound and video, the
stage size, frame rate and colours, the grid, guides, snapping and print settings, the
swatches, fonts and publish profiles, and much more. The timelines are in their own
streams, and Contents is what names them. It is an
MFC archive, little-endian, with UTF-16
strings.
The layout is that of the JPEXS FLA converter’s reader. Over the 322 documents of Flash MX 2004, 8, CS3 and CS4 examined, it reads the whole stream, field by field, to its last byte in nearly every one.
Document revision
The first byte of the stream is the document revision. It names the release that last saved the document, and it is how the explorer tells this format from the Flash MX and earlier one.
| Revision | Release |
|---|---|
0x38 | Flash MX 2004 |
0x3F | Flash 8 |
0x43 | Flash CS3 |
0x47 | Flash CS4, and the Save as CS4 option of later releases |
Every field below that is marked with a revision is present only when the document revision is at least that value. Revisions between those of the releases are not known from any file; a reader that tests each field by its threshold reads them all the same way.
Layout
| Field | From | Meaning |
|---|---|---|
| u8 | always | The document revision. |
| u32 | 0x20 | 1 in the Flash MX 2004 and Flash 8 files seen, 0 in the CS3 and CS4 files; the JPEXS reader calls it a compatibility marker. Its meaning is not established. |
| u32 + objects | always | The number of embedded OLE objects, then that many CSketchCntrItem objects. 0 in every file seen. |
| u8, u8 | 0x14, 0x15 | Not established. |
| 4 bytes each | 0x21, 0x2B, 0x3B, 0x40, 0x44 | Five blocks of four bytes, one for each of these revisions. Not established. |
| objects | always | The scenes, one CDocumentPage each, in order, ended by 00 00. |
| u16, u16 | always | The numbers the next new scene and the next new item will get. |
| object | always | The scene that was open: a reference to one of the scenes above. |
| objects, u16 | always | The library: a CDocumentPage per symbol and a CSwfPage per compiled clip, ended by 00 00; then a counter. |
| objects, u16 | always | The media records, ended by 00 00; then a counter. |
| u16 | always | Ruler units: 0 inches, 1 decimal inches, 2 points, 3 centimetres, 4 millimetres, 5 pixels. |
| u8 | always | The grid: 0 hidden, 3 shown. Other values are not established. |
| 4 × s32 | always | The stage: left, right, top and bottom in twips. A 550 × 400 stage is 0, 11000, 0, 8000. |
| u32 | always | The grid’s horizontal spacing, in twips as a 16.16 fixed-point number. |
| u8, u8, u8 | always | Preview mode (0 outlines, 1 fast, 2 anti-alias, 3 anti-alias text, 4 full), rulers shown, and a byte not established. |
| u8, u8 | always | View and play options, bits: 0x01 animation controls shown, 0x02 buttons active, 0x04 paste board, 0x08 live preview, 0x10 loop, 0x20 play all scenes, 0x40 play frame actions, 0x80 play sounds; then a byte not established. |
| 4 × s32 | always | Print margins: left, right, top, bottom, in twips. |
| u8, u8, u8, u8 | always | Print centred horizontally, vertically; the print layout (its numbers are not named by any public source; the layouts XFL names are actual size, fit on one page, and storyboard as boxes, grid or blank); disable PostScript. |
| s32 | always | Print scale, 16.16 fixed point: 0x10000 is 100%. |
| u16 + bytes, u16 + bytes | always | The printer settings and printer names: Windows DEVMODE and DEVNAMES structures. |
| u32, u32 | always | The background colour and the grid colour (red, green, blue, alpha). |
| u32 | always | The frame rate, 16.16 fixed point: 0x00180000 is 24 frames a second. |
| u8, u8, u8, s32 | always | Print all frames, print frame labels, frames across a page, and the storyboard margin in twips. |
| publish settings | always | The Publish Settings dialog and its profiles. |
| string pairs | always | Properties kept for extensions. |
| colour list × 2 | always | The swatches, and a second list of swatches. |
| library view, folders | always | The Library panel’s settings, and the library’s folders. |
| named objects | 0x2D | A list of named objects for the whole document. |
| named objects × profiles | always | One list for each publish profile. |
| u16 | always | The number the next new symbol will get. |
| u32, u8, u8, u8 | always | Guides: their colour, shown, locked, snap to guides. |
| font list | always | The font symbols of the library. |
| CString | always | The address of the shared library this document uses. |
| u8, u8, u32, u32 | always | Snap to grid, snap to objects, grid snap accuracy (0 must be close, 1 normal, 2 can be distant, 3 always snap), guide snap accuracy (0 must be close, 1 normal, 2 can be distant). |
| u32 | always | The grid’s vertical spacing, as the horizontal. |
| CString, CString | always | For a document made as a template: its description and its file. |
| u32 | always | The preview frame. |
| u32, u32 | always | Pixel grid shown, snap to pixels. |
| accessibility | always | The whole document’s accessibility settings; from 0x2F with the tab index of the Unicode form. |
| u32 | always | The number the next new media item will get. |
| u8 × 4, u32 × 3 | 0x2E | Snap align: on, vertical centre, horizontal centre, border; then the horizontal, vertical and border spacing. |
| u8 | 0x30 | The outline flags of Flash MX 2004’s screens. |
| u8 + persistent data | 0x32 | Whether the document’s persistent data follows, set by extensions. |
| u32 | 0x33 | The tab order mode. The numbers are not named by any public source. |
| u32 | 0x34 | The document type, below. |
| u32 + languages | 0x35 | Whether the Strings panel’s language settings follow. |
| u32 + CString | 0x36 | When the u32 is 1, the language shown on the stage. |
| u32 | 0x38 | Export component schemas into the SWF. |
| CString | 0x3A | The document’s metadata, as XMP (XML). |
| CString | 0x3C | Mobile settings, as XML. |
| u32 | 0x3D | How the Strings panel replaces strings. The numbers are not named by any public source. |
| u32 + post-processor | 0x3E | Whether a post-processor record follows. |
| u32, s32 | 0x3F | The timeline panel’s height and the width of its layer names; above 0x47 the width is a float. |
| u32 | 0x41 only | Not established. |
| shared libraries | 0x42 | The runtime shared libraries the document uses. |
| writer | 0x43 | Four u16 and a short block that identify the program that wrote the file. |
| f64 | 0x45 | The 3D perspective angle, in degrees. |
| 2 × s32 | 0x46 | The 3D vanishing point, in twips. |
| u32 | 0x47 | Adjust the perspective angle with the stage size. |
| Document type | Meaning |
|---|---|
| 0 | A regular document with a timeline. |
| 1 | A Flash slide presentation (screens). |
| 2 | A Flash form application (screens). |
| 3 | A Flash document for ActionScript 2. |
| 4 | A Flash document for ActionScript 3. |
| 5 to 8 | AIR for desktop, Flash Lite, AIR for iOS, AIR for Android: values that belong to later releases. |
00000000 3F 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000010 00 00 00 00 00 00 00 FF FF 01 00 0D 00 43 44 6F .............CDo
00000020 63 75 6D 65 6E 74 50 61 67 65 17 06 50 00 61 00 cumentPage..P.a.
00000030 67 00 65 00 20 00 31 00 FF FE FF 07 53 00 63 00 g.e. .1.....S.c.
Contents stream of a Flash 8 document3F– document revision0x3F: Flash 801 00 00 00– the u32 present from revision0x20: 100 00 00 00– no embedded OLE objects- 14 zero bytes – the two bytes of revisions
0x14and0x15, then the 4 bytes of each of0x21,0x2Band0x3B; Flash 8 is below0x40 FF FF 01 00 0D 00 "CDocumentPage"– the first scene, an object of a new class17– the scene record’s revision,0x1706and 12 bytes – the stream namePage 1: 6 characters of UTF-16LE, no markerFF FE FF 07and 14 bytes – the scene’s nameScene 1, a Unicode CString
Scene and symbol records
Each scene, and each symbol of the library, is a CDocumentPage object.
The fields in the order they are written:
| Field | From | Meaning |
|---|---|---|
| u8 revision | always | 0x16 in Flash MX 2004, 0x17 in Flash 8, 0x18 in CS3, 0x19 in CS4; all seen in files. |
| stream name | always | A length byte, the number of characters, then UTF-16LE with no marker (single bytes below revision 0x15): Page 1, Symbol 12, or in Flash CS4 P 1 1227523356. |
| CString | always | The name as the user sees it: Scene 1, or the symbol’s name. |
| u32 | always | The library number, which instances use to point at the symbol. |
| u8 | always | The symbol type: 0 graphic, 1 button, 2 movie clip, 5 IK container (an armature). Type 4 was seen twice, in a Flash MX 2004 and a Flash 8 file; no public source names it. |
| CString | always | A legacy name. |
| u32 | always | Not established. |
| library metadata | always | The item’s folder, number, attributes, linkage and persistent data. |
| u32 | always | A time stamp. |
| CString, CString, property list | always | Legacy Smart Clip settings: the custom user interface file, the description and the parameters. |
| u32 | always | Parameters are locked (legacy). |
| linkage | always | The symbol’s linkage settings. |
| component | 0x12 | The symbol’s component definition. |
| CString, CString | 0x14 | Template name and template version. |
| u32, CString | 0x16 | The last unique identifier given out, and the data binding XML. |
| u32, 4 × s32 | 0x17 | 9-slice scaling: enabled, and the guides’ left, right, top and bottom in twips. |
| u8, 2 × s32 | 0x18 | Whether a transformation point is set, and the point in twips. |
| u8, u8 | 0x19 | Is a Flex component, is a subclass of Sprite. |
A scene’s record has the same fields as a symbol’s. Revisions below
0x16 have the further legacy fields given on the
Flash MX and earlier page.
The explorer lists every scene and symbol with its stream, type and linkage.
Component definition
Written with no class tag: a u8 revision (5 in Flash MX 2004, 6 in Flash 8, 7 in CS3 and CS4), then:
| Field | From | Meaning |
|---|---|---|
| u32, CString, u32, u32, u32 | always | Enabled as a component, its tooltip, its custom icon number, parameters locked, and the description type. |
| CString | always | The ActionScript class. |
| 3 × clip movie | always | Three clip movies. The custom user interface and the live preview are among them; which is which is not established. |
| CString, property list | 1 | The description and the parameters. |
| CString | 2 | The class’s properties as XML. |
| s32 + tasks | 4 | Tasks: each a description and a script, both CStrings. |
| u32 + bitmap | 5 | When the u32 is not 0, an icon bitmap: a bitmap record and its raster. |
| u32 | 6 | Not established. |
| u32, CString, u32, u32 | 7 | The frame to edit, and the minimum Flash Player (as a name and a number) and ActionScript version it needs. |
| clip movie | 8 | A live preview movie for Flash Player 11. |
Clip movie
A u8 revision (3 in every file seen); from 1 a CString name, a u32 byte count and that many bytes (a SWF); from 2 a further u32.
Compiled clips
A compiled clip in the library is a CSwfPage: the common part of a
media record, a component
definition, then a u8 revision (4 in Flash 8, 5 in CS4); from 1 a CString source
name; from 2 four s32 bounds; from 3 the SWC metadata below; from 4 three u32 (one
not established, the Flash Player version and the ActionScript version); from 5 a u32
and either a shared library record or a CString, the
export name.
SWC metadata: a u8 revision (4 in every file seen), CStrings for the name and the implementation, a u32 version, an is-top-level flag (u8 at revision 1, u32 from 2); at revision 2 a list of children; from 3 three lists, the asset map (each entry a CString key and metadata), the includes and the export-after lists (each entry metadata); from 4 the intrinsic class name and script. Each list is a u32 count and its entries.
Library metadata and linkage
Library metadata is written with no class tag: a u32 revision (6 in every file of this format), then an item number for the parent folder, one for the item itself, a u32 of attributes (not established), the linkage, and a u8 that says whether persistent data follows. An item number is a u32 marker, and when it is not 0, two more u32. Revisions below 4 used plain u32 numbers.
Linkage
A u8 revision (5 in Flash MX 2004, 7 from Flash 8), a u32 mode (0 none, 1 export, 2
import), a CString identifier, a CString address (the shared library’s URL for an
import), from 5 a CString class name, a u8 of export flags (0x01 export
for ActionScript, 0x02 export for runtime sharing, 0x04
export in first frame), the source record below, from 6 a u8 import type and from 7 a
CString base class.
The source record, for a symbol kept up to date from another document: a u32 revision (2), a CString path, a CString item name, a u32 time of the last change, a u32 update automatically, then an item number.
Media records
Each Media stream has a record in Contents: class
CMediaBits for a bitmap, CMediaSound for a sound,
CMediaVideoStream for embedded video and CMediaVideo for
linked video. All start with the same part:
| Field | From | Meaning |
|---|---|---|
| u8 revision | always | 6 from Flash MX 2004 to CS3, 7 in CS4. |
| stream name | always | A length byte, then UTF-16LE: Media 13, or in Flash CS4 M 13 … with a time stamp. |
| CString | always | The item’s name in the library. |
| u16 | always | The media number, which bitmap fills, bitmaps on the stage and frame sounds use to point at it. |
| CString | always | The path of the imported file, such as .\b\020000.gif. |
| u32 | always | The imported file’s time stamp. |
| library metadata | always | Folder, number, linkage and persistent data. |
| u32 | always | The platform the file was imported on. |
A bitmap (CMediaBits) goes on with a u8 revision (3, and 4 in CS4), a u8
compression mode, a u8 JPEG quality (0 to 100), a u8 allow smoothing, an s32 length of
the JPEG data (0 for a lossless bitmap) and from revision 4 a u8 use deblocking.
Compression modes 0, 1 and 2 occur; which is which setting is not established.
A sound (CMediaSound) goes on with a u8 revision (9 in Flash MX 2004,
0x0A in CS4), a u16 of format flags, a u32 sample count, two s16 (the
publish format and bits), a u32 length of the encoded data, a u8 flag for imported MP3
quality, a second u16 of format flags and u32 sample count (those of the uncompressed
copy that follows a compressed sound in its Media stream), from revision 9 a CString
device sound address, and from 0x0A a u32 use 8 kHz rate.
| Format flag bits | Meaning |
|---|---|
0x01 | Stereo (clear: mono). |
0x02 | 16-bit (clear: 8-bit). |
0x0C | The rate: 0 5,512 Hz, 1 11,025 Hz, 2 22,050 Hz, 3 44,100 Hz. |
0xF0 | The codec: 0 PCM in the computer’s byte order, 1 ADPCM, 2 MP3, 3 PCM little-endian, 4 GSM, 5 Nellymoser 8 kHz mono, 6 Nellymoser. |
So 0x0A is 22,050 Hz 16-bit mono, 0x0F 44,100 Hz 16-bit
stereo and 0x2B 22,050 Hz 16-bit stereo MP3. The publish format and bits
are the numbers XFL writes as exportFormat
and exportBits: −1 in both, the usual value, means the document’s
publish setting; the bits are the MP3 bit rate (6 for 8 kbit/s up to 17 for 160), 2 +
the ADPCM code size, 18 for Speex, or 0 for uncompressed; the format adds 1 for stereo,
2, 6, 10 or 14 for a rate of 5.5, 11, 22 or 44 kHz, and for MP3 4 for best quality.
The number that picks the codec is not established. The explorer writes each sound’s
setting out. A video record is the common part alone; linked video adds a u8 revision. The
data itself is described in Bitmaps and
sounds.
Publish settings
The settings of the Publish Settings dialog are kept as string
pairs, a key and a value, both as text. The key names a group and a setting,
joined by ::. Below revision 0x2C there is one list of pairs.
From 0x2C there are publish profiles: from 0x2D first a list of
pairs for the document, then a u32 number of profiles and one list of pairs for each.
After them come a u32, two CStrings and a u32, whose meanings are not established.
Which profile is the current one is not established for a binary document (an XFL
document marks it); the explorer shows every profile, each in its own table. A Flash 8
document holds keys such as PublishFormatProperties::htmlFileName
(game.html), PublishProfileProperties::name (Flash 8
Settings) and Vector::Debugging Permitted (0). The
ones that matter most to a reader:
| Key | Example value | Meaning |
|---|---|---|
PublishFormatProperties::flash | 1 | Publish a SWF file. The group has a switch like it for each format: flash, html, gif, jpeg, png, projectorWin, projectorMac, qt (QuickTime) and rnwk (RealPlayer), and a file name for each. |
PublishFormatProperties::flashFileName | game.swf | The name of the SWF file to publish. |
Vector::Version | 6 | The Flash Player version the SWF is made for. |
Vector::Compress Movie | Whether the SWF is compressed. | |
Vector::ActionScriptVersion | 1 | The ActionScript version the scripts are compiled as: 1, 2 or, from CS3, 3. |
Vector::DocumentClass | AvatarChat | Flash CS3 and CS4: the ActionScript 3.0 document class, found as an .as file on the class path. |
Vector::AS3 Package Paths | Flash CS3 and CS4: the class path for ActionScript 3.0 source. | |
Vector::AS3 Library Paths | Flash CS3 and CS4: the folders and SWC libraries to link. | |
PublishHtmlProperties::…, PublishGifProperties::… and so on | The settings of each other tab. PropSheet::ActiveTab is the tab that was open. |
The keys are the same words as the elements of an XFL document’s PublishSettings.xml. The explorer shows the SWF’s name, the target Flash Player version, the ActionScript version and the document class in its Document section. See classes and the document class.
String pairs
A count, then each pair as two CStrings. A count here is a u16; if it is
FFFF a u32 follows with the real count.
Named objects
The same, but each value is an object with its class tag instead of a CString.
Swatches
A colour list is a count (as above), that many CColorDef objects, then a
u8 revision (0, and 1 in CS4); at revision 1 a u8 count of nested lists follows, each a
colour list. CColorDef is a class with schema 0:
| Field | From | Meaning |
|---|---|---|
| u8 revision | always | 3 in Flash MX 2004, 4 from Flash 8. |
| u32 | 2 | The colour (red, green, blue, alpha). |
| u8 | 2 | Flags: 0x10 a gradient (0x12 radial), 0x20 extended, as in a fill. |
| u8 | 2 | Secondary flags; not established. |
| gradient | flag 0x10 | Six s32 of a matrix, a u8 stop count, from revision 4 the focal point and gradient flags of a gradient fill, then the stops (a u8 ratio and a u32 colour each). |
| extended | flag 0x20 | Six s32, a u32 and four u16; not established. |
| 3 × u16 | 1 | Hue, saturation and brightness, as the colour mixer shows them. |
Library view, folders and fonts
The library view: a u32 revision (3 in every file seen), seven s32, from 2 two u32 and from 3 another u32. What each number holds is not established.
The folders: a u32 that is not established, a u32 count, then each folder as a u32 revision (4 in every file seen), a CString name, at revision 2 a u32, and its library metadata.
The font list, the library’s font symbols: a u32 not established, a u32 count, then each font as a u8 revision (3 in CS4), a CString name, a u16 font number, a u32 time stamp, a text style giving the font, its library metadata, and from revision 3 a u32 of flags.
Persistent data, languages and the rest
Persistent data, which extensions attach to the document, to library items and to instances: a u32 not established, an s32 count, then each value as a u8 type, a CString name and the value: type 0 an s32, 1 a u32 count and that many s32, 3 an f64, 4 a u32 count and that many f64, 5 a CString, 7 a u32 count and that many bytes. Types 2 and 6 are not known.
Languages (the Strings panel): an s32 count, a CString address of the language files, a u32 detect automatically, a CString default language, then that many CStrings, the languages.
Post-processor: a GUID (u32, u16, u16, 8 bytes), a CString name, an s32 byte count and that many bytes.
Writer: four u16, then a u16 byte count and that many bytes when it is 256 or less. No public source says how to read them.
A CPicFont on the stage uses the same font record as the
font list above; see other
objects.
Streams that end differently (decompiler output)
Twenty-one local files are output of a SWF decompiler, not of Adobe Flash, and their Contents streams do not end where the revision says:
- Revision
0x43, one byte too many: sixteen files have one byte left after the writer fields. The explorer shows it in the Document settings as “Unread bytes at the end” (what it is for is not known). - Revision
0x3f, four bytes too few: five files stop exactly where the last field,timelineLabelWidth, begins. The explorer keeps every field before it, shows “Stream ends early” with the byte it stops at, and does not call the document damaged. The rule: a revision0x3for later stream that ends within 3 bytes of the end of the tail fields is read this way; any other stop is reported as a problem as before.
The Flash MX form, four zero bytes after the last field, is on the Flash MX and earlier page.
In the explorer
The Document section shows every field above with its meaning: the release, the stage size in pixels, the frame rate, the colours, rulers, grid, guides, snapping, print and view settings, the document type, languages, persistent data, the 3D view and the writer. The library, media records, swatches, fonts and each publish profile have their own tables.