The Contents stream is the document itself: which release saved it, the
scenes in order, the library, a record for every imported bitmap and sound, the stage
size, frame rate and colours, the grid, guides and print settings, the swatches and the
publish settings. The timelines are in their own streams, and Contents is
what names them. It is an MFC archive,
little-endian, with single-byte strings.
The layout is that of the JPEXS FLA converter’s reader. Over the 1,326 documents of Flash 3, 4, 5 and MX 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 2004 to CS4 one.
| Revision | Release |
|---|---|
0x10 | FutureSplash Animator and Flash 1 (from the JPEXS converter; not seen in a file) |
0x11 | Flash 2 (from the JPEXS converter; not seen in a file) |
0x14 | Flash 3 |
0x1B | Flash 4 |
0x20 | Flash 5 |
0x29 | Flash MX |
Every field below that is marked with a revision is present only when the document revision is at least that value. The reader also knows a revision 1, whose stream is only a list of objects; no file of it is known.
Layout
| Field | From | Meaning |
|---|---|---|
| u8 | always | The document revision. |
| u32 | 0x20 | 1 in every Flash 5 and Flash MX file seen; the JPEXS reader calls it a compatibility marker. What else it could hold is not established. |
| u32 + objects | always | The number of embedded OLE objects, then that many CSketchCntrItem objects. 0 in every file seen. |
| u8 | 0x14 | Not established. |
| u8 | 0x15 | Not established. |
| 4 bytes | 0x21 | Not established. |
| objects | always | The scenes, one CDocumentPage each, in order, ended by 00 00. |
| u16 | always | The number the next new scene will get. |
| u16 | always | The number the next new item will get. |
| object | always | The scene that was open: a reference to one of the scenes above. |
| objects, u16 | 0x0E | The library: one CDocumentPage per symbol, ended by 00 00; then a counter. |
| objects, u16 | 0x11 | The media records, ended by 00 00; then a counter. |
| u16 | 0x11 | 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 | always | Preview mode: 0 outlines, 1 fast, 2 anti-alias, 3 anti-alias text, 4 full. |
| u8 | always | Rulers shown. |
| u8 | always | Not established. |
| u8 | 0x0F | 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. |
| u8 | 0x0F | Not established. |
| 4 × s32 | always | Print margins: left, right, top, bottom, in twips. |
| u8, u8 | always | Print centred horizontally, vertically. |
| u8 | always | Print layout. The 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. |
| u8 | always | Disable PostScript. |
| s32 | always | Print scale, 16.16 fixed point: 0x10000 is 100%. |
| u16 + bytes | always | The printer settings: a Windows DEVMODE structure. |
| u16 + bytes | always | The printer’s names: a Windows DEVNAMES structure. |
| u32, u32 | 0x0B | The background colour and the grid colour (red, green, blue, alpha). |
| u32 | 0x0D | The frame rate, 16.16 fixed point: 0x000C0000 is 12 frames a second. |
| u8, u8, u8, s32 | 0x10 | Print all frames, print frame labels, frames across a page, and the storyboard margin in twips. |
| publish settings | 0x13 | The Publish Settings dialog. |
| string pairs | 0x15 | Properties kept for extensions. |
| colour list × 2 | 0x16 | The swatches, and a second list of swatches. |
| library view | 0x18 | The Library panel’s settings. |
| folders | 0x19 | The library’s folders. |
| named objects | 0x1A | A list of named objects belonging to the publish settings. |
| u16 | 0x1B | The number the next new symbol will get. |
| u32, u8, u8, u8 | 0x1C | Guides: their colour, shown, locked, snap to guides. |
| font list | 0x1D | The font symbols of the library. |
| CString | 0x1E | The address of the shared library this document uses. |
| u8, u8 | 0x1F | Snap to grid, snap to objects. |
| u32 | 0x1F | Grid snap accuracy: 0 must be close, 1 normal, 2 can be distant, 3 always snap. |
| u32 | 0x1F | Guide snap accuracy: 0 must be close, 1 normal, 2 can be distant. |
| u32 | 0x1F | The grid’s vertical spacing, as the horizontal. |
| CString, CString | 0x22 | For a document made as a template: its description and its file. |
| u32 | 0x23 | The preview frame. |
| u32, u32 | 0x24 | Pixel grid shown, snap to pixels. |
| accessibility | 0x26 | The whole document’s accessibility settings. |
| u32 | 0x27 | The number the next new media item will get. |
Flash MX (0x29) ends there. The fields of later revisions are on the
Flash MX 2004 to CS4 page.
20 01 00 00 00 00 00 00 00 00 00 FF FF 01 00 0D 00 43 44 6F 63 75 6D 65 6E 74 50 61 67 65
0C 06 50 61 67 65 20 31 07 53 63 65 6E 65 20 31 …
Contents stream of a Flash 5 document20– document revision0x20: Flash 501 00 00 00– the u32 present from revision0x20: 100 00 00 00– no embedded OLE objects00 00– the two bytes present from0x14and0x15; Flash 5 is below0x21, so the 4 bytes of that revision are absentFF FF 01 00 0D 00 "CDocumentPage"– the first scene, an object of a new class0C– the scene record’s revision,0x0C06 "Page 1"– the stream that holds the scene’s timeline07 "Scene 1"– the scene’s name, a 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 | 3 in Flash 1 and 2, 4 in Flash 3, 8 in Flash 4, 0x0C in Flash 5, 0x11 in Flash MX. |
| stream name | always | A length byte, then single bytes: Page 1 or Symbol 12, the stream holding the timeline. A zero byte may end it. |
| CString | always | The name as the user sees it: Scene 1, or the symbol’s name. |
| u32 | 2 | The library number, which instances use to point at the symbol. |
| u8 | 3 | The symbol type: 0 graphic, 1 button, 2 movie clip. |
| CString | 6 | A legacy name. |
| u32 | 7 | Not established. |
| library metadata | 5 | The item’s folder, number, attributes and linkage. |
| u32 | 8 | A time stamp. |
| 4 × command list | 9 only | Four lists of action commands. |
| CString, CString | 10 | Smart Clip settings: the custom user interface file and the description. |
| property list | 10 | The clip parameters a Smart Clip or component defines. |
| u32 | 11 | Parameters are locked. |
| linkage | 12 | The symbol’s linkage settings. |
| CString | 14 to 17 | The component’s name. |
| 2 × clip movie | 15 to 17 | The custom user interface and live preview movies. |
| u32 | 16 and 17 | The description type. |
| u32, CString, u32 | 17 only | Component enabled, its tooltip and its icon number. |
Revisions 4, 8, 0x0C and 0x11 were seen in files; revision 3 is
from the JPEXS converter. A scene’s record has the same fields as a symbol’s. The
explorer lists every scene and symbol with its stream, type and linkage.
Clip movie
A u8 revision; from 1 a CString name, a u32 byte count and that many bytes (a SWF); from 2 a further u32.
Library metadata and linkage
Library metadata is written with no class tag of its own: a u32 revision (4 in Flash 4, 5 in Flash 5 and MX), then
| Field | From | Meaning |
|---|---|---|
| u32, or an item number | always | The parent folder: a u32 up to revision 3, an item number from 4. |
| u32, or an item number | 2 | The item’s own number, in the same two forms. |
| u32 | 3 | Attributes; not established. |
| linkage | 5 | The linkage settings. |
An item number is a u32 marker, and when it is not 0, two more u32.
Linkage
A u8 revision (0 in Flash 5, 3 in Flash MX), then a u32 mode (0 none, 1 export, 2
import), a CString identifier, a CString address (the shared library’s URL for an
import); from revision 5 a class name; from 1 a u8 of export flags
(0x01 export for ActionScript, 0x02 export for runtime
sharing, 0x04 export in first frame); from 2 the source record below; from
6 a u8 import type; from 7 a base class.
The source record, for a symbol kept up to date from another document: a u32 revision (1 in Flash MX), a CString path, a CString item name, a u32 time of the last change, from 1 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 (Flash MX) and
CMediaVideo for linked video. All start with the same part:
| Field | From | Meaning |
|---|---|---|
| u8 revision | always | 3 in Flash 3, 4 in Flash 4, 5 in Flash 5 and MX. |
| stream name | always | A length byte, then single bytes: Media 13. |
| 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 | 2 | The path of the imported file, such as .\b\020000.gif. |
| u32 | 3 | The imported file’s time stamp. |
| library metadata | 4 | Folder, number and linkage. |
| u32 | 5 | The platform the file was imported on. |
A bitmap (CMediaBits) goes on with a u8 revision (3 in every release of
this format); below revision 2 a CString path; from 1 a u8 compression mode and a u8
JPEG quality (0 to 100); from 2 a u8 allow smoothing; from 3 an s32, the length of the
JPEG data, 0 for a lossless bitmap. Compression modes 0, 1 and 2 occur; which is which
setting is not established.
A sound (CMediaSound) goes on with a u8 revision (5 in Flash 3, 7 in
Flash 5, 8 in Flash MX); at revision 2 a CString; a u16 of format flags; a u32 sample
count; from 4 two s16, the publish format and bits; from 6 a u32 length of the encoded
data and a u8 flag for imported MP3 quality; from 7 a second u16 of format flags and a
second u32 sample count: those of the uncompressed copy that follows a compressed
sound in its Media stream.
| 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 0x2F the same in MP3. Below sound revision 5, 4 is added to
the flags before they are read. 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, 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 ::. After the pairs come a u32, two CStrings and a u32, whose
meanings are not established.
| 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), rnwk (RealPlayer) and generator, and defaultNames. |
PublishFormatProperties::flashFileName | mixer.swf | The name of the SWF file to publish; the group has a file name for each format. |
Vector::Version | 6 | The Flash Player version the SWF is made for. |
Vector::… | The other settings of the Flash tab, such as compression, protection and JPEG quality. | |
PublishHtmlProperties::…, PublishGifProperties::… and so on | The settings of each other tab: PublishHtmlProperties, PublishGifProperties, PublishJpegProperties, PublishPNGProperties and so on. 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 lists every pair in a Publish settings table, and shows the SWF’s name and the target Flash Player version in its Document section.
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 in this format); at revision 1 a u8 count of nested lists follows.
CColorDef is a class with schema 0:
| Field | From | Meaning |
|---|---|---|
| u8 revision | always | 3 in every file of this format seen. |
| 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 and 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. |
Below revision 2 the colour part is two bytes, two u32, a u16, six s32 and four u16, from the JPEXS reader. Gradients appear in the swatches from Flash 4 on.
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 (3 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, 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.
Bytes after the last field
A regular revision 0x29 (Flash MX) stream ends with nextMediaIdentifier.
The Flash MX files of the 5444 template pack end with four more bytes, all
zero (eight files, and 5132.fla). No field is known for them. The explorer
shows them in the Document settings as “Unread bytes at the end” with their values, and
reads the rest of the stream as complete; earlier versions took them for the start of a
shared-library list and reported the stream as cut short. For the matching forms in
Flash MX 2004 and later see Contents
in Flash MX 2004 to CS4.
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 library, media records, swatches and publish settings each have their own table.