Flash for Windows was written with Microsoft’s MFC library, and it saves its documents
the MFC way: each object writes its own fields into a CArchive, and MFC adds
tags that say which class each object belongs to. Every stream of an FLA except the Media
streams is such an archive. The class tags and strings below are MFC’s own scheme; the
records inside are Flash’s. All numbers are little-endian.
The start of a stream
A Contents, Page or Symbol stream starts with
one byte. In a timeline stream it is 01, and the root object, a
CPicPage, follows with its class tag. In Contents the first
byte is the document revision, and the document’s fields follow directly; see
The Contents stream.
Strings
Text is written in MFC’s CString archive form, and in this format in its
Unicode form: the three bytes FF FE FF, then the length in characters,
then the characters in UTF-16LE.
| Length in characters | Written as, after FF FE FF |
|---|---|
| 0 to 254 | One byte, the length |
| 255 to 65,533 | FF, then the length as a u16 |
| more | FF FF FF, then the length as a u32 |
FF FE FF 06 73 00 74 00 6F 00 70 00 28 00 29 00 ....s.t.o.p.(.).
FF FE FF 00
FF FE FF F9 2F 00 2F 00 …
stop(), an empty frame label, and a 249-character script that starts //No terminating zero is written. The marker works because FF FE as a u16
after FF is a length MFC never writes in the single-byte form, so a reader
can test every string: FF FE FF means UTF-16, anything else a single-byte
string with a length of 0 to 254 bytes, or FF and a longer length. Single-
byte strings still occur in this format, in streams last written by Flash MX or earlier
(see documents that mix
encodings); a reader should test each one.
Stream names inside Contents are written differently from CStrings: one
length byte, the number of characters, then UTF-16LE with no marker. See
Stream names and display
names.
Revisions
Flash’s records version themselves. Every record starts with its own revision byte,
and each release that changed a record raised its revision and added fields at the end.
A reader reads the revision first and then only the fields that revision has, so one
reader can read every release of this format. The object part that every timeline
object starts with is revision 2 in Flash MX 2004, 4 in Flash 8 and 5 in CS3 and CS4; a
frame record went from 0x17 in Flash MX 2004 to 0x1D in CS4.
The values of each release are on the Versions
page, and each record’s fields by revision on
Pages, layers and frames.
Flash rewrites only the streams that changed, so a timeline stream can be older than
the document around it. A reader should take each stream’s revisions from the stream
itself, starting with the byte after the class name CPicPage, not from the
document revision.
Classes
Every class a binary FLA is known to hold. Those marked “seen” were found in the Flash MX 2004 to CS4 files examined for this site; the others are known from the JPEXS reader. The schema number in the class tag is 1, except for the four classes marked 0.
| Class | Where | What it is |
|---|---|---|
CPicPage (seen) | timelines | A timeline, the root of a Page or Symbol stream: page. |
CPicLayer (seen) | timelines | A layer. |
CPicFrame (seen) | timelines | A keyframe, with the shape drawn on it, its sound, label, script and tween. |
CPicObj | timelines | The bare object part. |
CPicShape (seen) | timelines | A shape object or drawing object; also the root of a stream that holds a bare shape. |
CPicRect (seen), CPicOval | timelines | Flash CS4’s rectangle and oval primitives. |
CPicMorphShape (seen), CMorphSegment, CMorphCurve, CMorphHintItem | timelines | A shape tween and its parts: morph shapes. |
CPicSymbol (seen), CPicShapeObj | timelines | A graphic symbol’s instance. |
CPicSprite (seen), CPicButton (seen), CPicScreen (seen) | timelines | Movie clip, button and screen instances. |
CPicText (seen) | timelines | A text field. |
CPicBitmap (seen), CPicVideoStream (seen), CPicVideo, CPicSwf (seen), CPicOle, CPicTLFText, CPicASObj, CPicThreeDObject, CPicFont, CPicSoundCreator, CCommandObj, CPicTempClipboardObj | timelines | The other objects: bitmaps, video, compiled clips, OLE objects, TLF text, runtime and 3D objects, font references, sounds, Generator commands and clipboard placeholders. |
CDocumentPage (seen) | Contents | A scene or symbol record. |
CSwfPage (seen) | Contents | A compiled clip in the library. |
CMediaElem | Contents | The bare media record. |
CMediaBits (seen), CMediaSound (seen), CMediaVideoStream (seen), CMediaVideo | Contents | The media records of bitmaps, sounds, embedded and linked video. |
CColorDef (seen, schema 0) | Contents | A swatch. |
CColorList (schema 0) | Contents | A list of swatches, when written as an object. |
CSketchCntrItem (schema 0) | Contents, timelines | An embedded OLE item: a u32 signature (0x100), u32 item number, u32, u16, u32 draw aspect, u8 revision, u16 item number and a scene record. |
CObList (schema 0) | anywhere | MFC’s own list class: a count, then the objects. Older files keep shape hints in one. |
CQTAudioSettings | not established | QuickTime audio settings: a u32 byte count and that many bytes, not established. |
The class names are Flash’s own, as they appear in the files; Macromedia and Adobe never documented them. An unknown class stops a reader, since nothing says how long its object is; the explorer reports where.
Worked example
The first 64 bytes of the Page 1 stream of a Flash 8 document:
00000000 01 FF FF 01 00 08 00 43 50 69 63 50 61 67 65 04 .......CPicPage.
00000010 00 FF FF 01 00 09 00 43 50 69 63 4C 61 79 65 72 .......CPicLayer
00000020 04 00 FF FF 01 00 09 00 43 50 69 63 46 72 61 6D ........CPicFram
00000030 65 04 00 FF FF 01 00 0A 00 43 50 69 63 53 70 72 e........CPicSpr
01– the stream’s first byte: the root object followsFF FF 01 00 08 00 "CPicPage"– a new class, schema 1, an 8-byte name (index 1; the page takes index 2)04 00– the page’s object part: revision 4, which says Flash 8, and flags 0; its children followFF FF 01 00 09 00 "CPicLayer"– the first child, a layer of a new class (indexes 3 and 4), then04 00FF FF 01 00 09 00 "CPicFrame"– the layer’s first frame (indexes 5 and 6), then04 00FF FF 01 00 0A 00 "CPicSprite"– the first thing on the stage in that frame, a movie clip instance
The same stream in a Flash MX document has 01 where this one has
04. Only after the instance, the frame’s other children and the end tag
00 00 come the frame’s own fields, and after all the frames, the layer’s
name. See Pages, layers and
frames.