Every movie starts with a header of six fields. The first three, 8 bytes, are always the same size; the frame size is a bit-packed rectangle whose size depends on the numbers in it, so the frame rate, the frame count and the first tag move with it. With the usual 15-bit values the header is 21 bytes and the first tag starts at offset 0x15.
00000000 46 57 53 06 75 1D 00 00 78 00 05 5F 00 00 0F A0
00000010 00 00 0C 01 00
FWS, version 6, 7,541 bytes, a
550 × 400 pixel stage, 12 frames a second, one frameFields
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 3 | UI8[3] | Signature | FWS (46 57 53): an uncompressed movie |
| 3 | 1 | UI8 | Version | The SWF version, 6 or more |
| 4 | 4 | UI32 | FileLength | The length of the whole file in bytes, these 8 included |
| 8 | varies | RECT | FrameSize | The stage, in twips; 9 bytes with 15-bit values |
| after | 2 | UI16 (8.8) | FrameRate | Frames a second, 8.8 fixed point |
| after | 2 | UI16 | FrameCount | The number of frames on the main timeline |
The tags follow directly.
Signature
Three bytes, FWS (46 57 53). The last two letters,
WS, are the same in every SWF file; the first says how the rest is
stored, and F means it is not compressed. A file starting
CWS or ZWS is a compressed movie, which is a different
format.
Version
One byte: the SWF version, the Flash Player the movie was made for. In this format it is 6 (Flash Player 6, 2002) or more; AIR 51 writes 51. The version decides which tags, actions and flags a reader can expect, and the player runs a movie by the rules of its version: from SWF 7 ActionScript names are case-sensitive, and from SWF 9 a movie whose FileAttributes sets the ActionScript3 flag runs on the AVM2. The versions table lists every version.
The explorer accepts any version from 6 and notes one above 60 as newer than any known.
File length
A UI32: the length of the whole movie in bytes, the header included. In this format it equals the size of the file.
In the example, 75 1D 00 00 is 0x1D75, 7,541 bytes.
Frame size
A RECT: a 5-bit count
Nbits, then Xmin, Xmax, Ymin and
Ymax, each a signed Nbits-bit number, padded to a whole
byte. The values are in twips, 20 to a pixel. Xmin and
Ymin are normally 0, so Xmax and Ymax are the
stage’s width and height.
The example’s nine bytes 78 00 05 5F 00 00 0F A0 00, as bits:
01111 000000000000000 010101011111000 000000000000000 001111101000000 0000000
Nbits Xmin Xmax Ymin Ymax padding
15 0 11000 0 8000
Frame rate
Frames a second, as an unsigned 8.8 fixed-point number stored little-endian: the
first byte is the fraction in 256ths, the second the whole number. 00 0C
is 12.0, 00 1E is 30.0 and 00 3C is 60.0. The player tries to
show frames at this rate.
Frame count
A UI16: the number of frames on the main timeline, which is the number of
ShowFrame tags in the
movie’s own tag run, not counting those inside sprites. In the example
01 00 is one frame.