Every bitmap or sound imported into the library is kept in a
Media stream of its
own. Unlike the other streams, a Media stream is not an archive of objects: it is the
data itself. What the item is called, and the file it came from, are in its
media record in
Contents. No thumbnail or preview image was found in any binary FLA.
JPEG
When the bitmap’s media record gives a JPEG length (from record revision 3), the
stream is that many bytes of a JPEG file, kept whole as it was imported, then four s32:
the bounds, left, right, top and bottom in twips. Reading the JPEG part gives a file
that any image program opens. The explorer shows it, however the stream’s sectors lie.
A stream that starts FF D8 FF E0 under an older record is read the same
way, with the last 16 bytes as the bounds.
Lossless bitmaps
Bitmaps that are not JPEGs are kept in Flash’s own lossless form, the raster: a short header, an optional palette, then the pixels, usually as a zlib stream split into chunks. Little-endian throughout.
| Field | Present | Meaning |
|---|---|---|
| u8 | always | The raster’s revision: 3 in every file of Flash 4, 5 and MX seen. |
| u8 | always | The pixel format, below. |
| u16 | always | Row size: bytes a row, with any padding. |
| u16, u16 | always | Width and height in pixels. |
| 4 × s32 | always | The bounds in twips (1/20 pixel): left, right, top, bottom; normally 0, width × 20, 0, height × 20. |
| u8 | revision 3 | Bit 0: the bitmap has transparency. |
| u16 + colours | format below 4 | The palette: a count (up to 256), then the colours, four bytes each from revision 3 (alpha, red, green, blue), earlier three u16 each (red, green, blue, the high byte being the value). |
| u8 | revision 2 or more | 1: the pixels are zlib data in chunks; 0: raw. Revision 1 is always compressed, revision 0 never. |
| chunks | compressed | Each a u16 length and that many bytes, until a length of 0. |
| row size × height bytes | raw | The pixels. |
| Format | Pixels |
|---|---|
| 5 | Four bytes a pixel: alpha, red, green, blue, the colours premultiplied by alpha (colour × alpha ÷ 256). |
| 3 | One byte a pixel, an index into the palette. About one bitmap in five in the files examined. |
| 4 | No palette; two bytes a pixel, read as a big-endian 16-bit word: bit 15 is unused, then 5 bits each of red, green and blue (bits 14 to 10, 9 to 5 and 4 to 0). JPEXS widens each 5-bit value to 8 bits with a 32-entry table, 0, 15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95, 95, 111, 119, 127, 135, 143, 151, 159, 167, 175, 183, 191, 199, 207, 215, 223, 223, 239, 247, 255. No file examined here holds this format. |
| 0 to 2 | These also have a palette, and each pixel is an index of 1 << format bits: 1 bit (format 0), 2 bits (1) or 4 bits (2), the first pixel of a byte in its high bits, rows padded to the row size. One Flash 5 file has format 0. |
The pixel formats 0 to 4 are as the JPEXS FLA converter reads them
(jpexs-fla-convert,
exporter/XflBitmapWriter.java, read 2026-11-13): the bits a pixel are 1
<< format below format 4, 16 in format 4 and 32 in format 5; the row size must be
at least that many bits a row; the colours are premultiplied by alpha; and when the
header’s transparency flag is 0 the bitmap is read as opaque whatever its alpha bytes
hold. The same converter’s BitmapRecordDecoder.java reads the header,
palette (formats below 4 only), compressed flag and chunks exactly as the table above
lays them out.
To decode a compressed raster:
- Join the chunks in order. The result is one zlib stream; it starts with the zlib
header, often
78 01. - Inflate it to row size × height bytes.
- Read the rows: four bytes a pixel in format 5, two in format 4, a palette index of 1 << format bits in formats 0 to 3.
03 05 A4 00 29 00 A0 01 00 00 00 00 34 03 00 00 00 00 00 00 80 20 00 00 00 01 02 00 78 01 …
78 01, the zlib headerEarlier pages here read the first two bytes, 03 05, as a signature; they
are the revision and the format. The same raster is used for the .dat
bitmaps of the later XFL documents. There, decoding a bitmap beside the PNG it was
imported from confirmed the order alpha, red, green, blue and the premultiplying; the
JPEXS converter writes Media streams in the same order. (Kreijstal’s notes give alpha,
blue, green, red.)
Sounds
An imported sound’s stream has no header of its own: its format, rate and length are
in the sound’s media record
in Contents, whose format flags give the codec, rate, sample size and
channels.
- PCM (codec 0 or 3): the samples, sample count × bytes a sample × channels bytes. 16-bit samples are signed little-endian; 8-bit samples are read as unsigned, as in WAV. JPEXS’s converter wraps these bytes unchanged in a WAV header (8-bit WAV data is unsigned), which is the only public support for that reading.
- A compressed codec (MP3 and the others): the encoded data, of the length the record gives; then a u8, and an uncompressed PCM copy of the sound in the record’s second format and sample count.
Every sound in the files examined is PCM or MP3: 8-bit and 16-bit, 5,512 to 44,100 Hz, mono and stereo. The explorer plays them all, decoding MP3 itself. For ADPCM, GSM and Nellymoser, which Flash names among its codecs, it plays the uncompressed copy when there is one. When there is not, the explorer shows the stored bytes as a labelled section: the codec number and name, the format, the sample count, the length of the compressed data, its first 32 bytes, and what follows them (the marker byte and the second format); the built test makes one sound each in ADPCM, GSM and Nellymoser.
What a public source settles, from the JPEXS FLA converter
(jpexs-fla-convert,
reader/MediaPayloadRecordDecoder.java, reader/FlaSoundFormat.java
and exporter/XflMediaWriter.java, read 2026-11-13): the stream is the
primary audio, then, for any codec other than 0, a marker byte and the second audio. The
primary audio is as long as the record’s encoded byte count when the codec is not 0 and
that count is above 0, otherwise sample count × bytes a sample × channels. The second
audio is the PCM size of the record’s second format and second sample count. A stream
that ends before the audio has run out is accepted as it is (the converter calls this
a short read). The codec number is bits 4 to 7 of the format word: 0 PCM, 1 ADPCM, 2
MP3, 3 PCM, 4 GSM, 5 Nellymoser 8 kHz mono, 6 Nellymoser, anything else unknown (the
converter says only the codec numbers named by Flash’s own sound-cache diagnostics are
named). The format word is stored 4 lower than it is read when the record’s revision is
below 5 (the converter adds 4), which this page’s explorer does too. For codec 1, 4,
5 and 6 the converter keeps the encoded bytes untouched and has no decoder: its own
warning is “no standalone source decoder for codec”. So the framing is public, and the
bit layout of the ADPCM, GSM and Nellymoser data inside is not: it is Unknown in the
Not described section of the family page.
Video
Flash MX added embedded video. A CMediaVideoStream’s stream holds:
| Field | Meaning |
|---|---|
| u8 | Revision: 2 in Flash MX. |
| u32 | The video type, the codec: 0 no media, 1 jpeg media, 2 h263 media, 3 screen share media, 4 vp6 media, 5 vp6 alpha media, 6 screen v2 video packet, 7 avc video packet, 8 count media type, any other number unknown. These are the names the JPEXS FLA converter writes into the XFL videoType attribute for each number (exporter/XflMediaWriter.java, method video, read 2026-11-13); they are the schema’s enumeration in the same order. |
| f64, f64 | Frame rate; audio sample rate. |
| s32, s32 | Audio bits a sample, audio channels. |
| s32, s32 | Width and height in pixels. |
| f64 | Length in seconds. |
| u32, u8, u8 | The isSpecial flag (the converter’s name for it; what it means is not established); import the audio; synchronise the video to the document’s frame rate. |
| u32, s32, f64, u32 | The import settings: frame drop ratio (an index), quality, scale and keyframe interval. |
| 2 tracks | Each a u32 kind, index entries (a non-zero u8, then s32 offset, byte count, frame count and flags) ended by a zero byte, then a u32 byte count and the data. |
| u32, CString, u32 + bytes | Revision 3 (Flash 8): a bundled device video. |
The explorer shows these fields, and every index entry of each track: its offset, byte count, frame count and flags. The tracks hold the video and sound as Flash compressed them on import (Sorenson Spark video in Flash MX). The explorer reads each entry’s bytes with the decoder of the codec the video type names, using the decoders it has for SWF and FLV and changing none of them: Sorenson H.263 (type 2, described in the SWF specification), Screen Video and Screen Video 2 (types 3 and 6), On2 VP6 and VP6 with alpha (types 4 and 5), and JPEG (type 1). When the entry reads as that codec’s picture, the explorer shows the picture type, size and quantiser (or the codec’s own header), and decodes the first and the last picture of the track as images; an entry that does not read as the named codec is tried as Sorenson H.263, then listed with the reason and its first bytes. Type 7 (AVC) is split into NAL units and its headers are read and the first and the last picture are drawn with the explorer's H.264 decoder (progressive streams); 0, 8 and unknown are listed, not decoded.
Established from 5 real files (the
0015_videos.fla files for CS4, CS3, Flash 8, Flash MX 2004 and Flash MX,
from jindrapetrik/flacomdoc
testdata/fla/, read 2026-11-13; the Flash MX one is this form): the
layout above is exactly what the file holds. Offsets count from the start of the
track’s data and the entries follow each other with no gaps. Each entry is one frame.
A Sorenson H.263 entry starts at the picture start code. A VP6 entry is an FLV video
tag body without its codec byte: one adjustment byte (0 in every entry read), then the
VP6 frame. The second track (kind 1) is the audio as raw little-endian PCM at the
rate, bits and channels in the header, in one entry. isSpecial is 0 in
every video read; its meaning is not known. The same detail is on
the CS4 page. The explorer
plays the audio track and decodes the H.263 and VP6 pictures. Not read from a real
file: Screen Video, JPEG, VP6 alpha, entries of more than one frame and AVC.