A CWS movie has two headers in one. The first 8 bytes of the file are not compressed: the signature, the SWF version and the length of the movie once decompressed. The rest of the header, the frame size, frame rate and frame count, is the first thing inside the zlib stream. Offsets for those fields are offsets in the decompressed data: the 8 header bytes followed by the inflated bytes, so the frame size is at offset 8, as in an uncompressed movie.
00000000 43 57 53 09 93 03 00 00 78 9C 7D 53 4D 4E DB 40
CWS, SWF 9, FileLength 915 bytes, then the zlib streamFields
All numbers are little-endian.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 3 | UI8[3] | Signature | CWS (43 57 53): everything after byte 7 is zlib-compressed. |
| 3 | 1 | UI8 | Version | The SWF version, 6 or later. |
| 4 | 4 | UI32 | FileLength | The length of the whole movie uncompressed, these 8 bytes included. Not the size of the file. |
| 8 | … | zlib stream | The rest of the file. See Compression. |
In the decompressed data:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 8 | 9 to 17 | RECT | FrameSize | The stage in twips; Xmin and Ymin are normally 0. |
| after | 2 | UI16 (8.8) | FrameRate | Frames a second: the first byte is the fraction (÷ 256), the second the whole part. |
| after | 2 | UI16 | FrameCount | The number of frames on the main timeline. |
| after | … | Tags | The tags, to the End tag. |
Signature
The three bytes CWS mark a movie compressed with zlib. The other SWF
signatures are FWS (uncompressed) and ZWS (LZMA); the
letters WS stay the same in all three. A tool that compresses or
decompresses a movie changes this one byte and the body, and keeps the version and
FileLength.
Version
The SWF version the movie was written for. It decides which tags and actions the player expects and how some of them are read. Flash Player 6 introduced zlib compression, so a CWS movie is SWF 6 or later. A CWS file whose header gives a lower version would not play in Flash Player; the explorer still opens it, notes the mismatch, and reads its strings and clip events as an SWF 5 movie’s. It also notes a version above 60 as newer than any known.
From Flash Player 10.1 the player’s version and the SWF version went separate ways. The versions a CWS movie can have:
| SWF | Flash Player (or AIR) | Released | Authoring tool |
|---|---|---|---|
| 6 | Flash Player 6 | March 2002 | Flash MX (March 2002) |
| 7 | Flash Player 7 | September 2003 | Flash MX 2004 (September 2003) |
| 8 | Flash Player 8 | September 2005 | Flash 8 (September 2005) |
| 9 | Flash Player 9 (AIR 1.0) | June 2006 | Flex 2 (2006); Flash CS3 (2007) |
| 10 | Flash Player 10.0 and 10.1 (AIR 1.5, 2.0, 2.5) | October 2008; June 2010 | Flash CS4 (September 2008), CS5 (April 2010) |
| 11 | Flash Player 10.2 (AIR 2.6) | February 2011 | Flash CS5.5 (2011) |
| 12 | Flash Player 10.3 (AIR 2.7) | May 2011 | |
| 13 | Flash Player 11.0 (AIR 3.0) | October 2011 | |
| 14 | 11.1 (AIR 3.1) | November 2011 | |
| 15 | 11.2 (AIR 3.2) | March 2012 | Flash CS6 (2012) |
| 16 | 11.3 (AIR 3.3) | June 2012 | |
| 17 | 11.4 (AIR 3.4) | August 2012 | |
| 18 | 11.5 (AIR 3.5) | November 2012 | |
| 19 | 11.6 (AIR 3.6) | February 2013 | Flash Professional CC (June 2013) |
| 20 | 11.7 (AIR 3.7) | April 2013 | |
| 21 | 11.8 (AIR 3.8) | July 2013 | |
| 22 | 11.9 (AIR 3.9) | October 2013 | |
| 23 | 12 (AIR 4.0) | late 2013 or January 2014 (sources differ) | |
| 24 to 43 | 13 to 32, one SWF version a major release (AIR 13 to 32) | April 2014 to 2018–2020 | Flash Professional CC 2014 and 2015; Adobe Animate (from February 2016) |
| 44 | Harman AIR 33.1 | ||
| 50 | Harman AIR 50 | ||
| 51 | Harman AIR 51 | 2024 onwards |
The last global Flash Player build was 32.0.0.465, in December 2020. The last edition of the specification is for SWF 19; later versions added no documented structures.
FileLength
The length of the movie when it is not compressed, counting the 8 header bytes. It is not the size of the CWS file, which is usually much smaller. Inflating the zlib stream should give exactly FileLength − 8 bytes; a reader can use it to size its output buffer and to check the result.
In the example above, 93 03 00 00 is 915: the stream inflates to 907
bytes, and the file itself is 645 bytes long. A second movie examined for this site
starts 43 57 53 08 72 EA 01 00 78 9C: SWF 8, FileLength 125,554 bytes
uncompressed, then the zlib header.
FrameSize
The first field inside the decompressed data, at offset 8: a RECT giving the stage in twips, twentieths of a pixel. A RECT is bit-packed: a 5-bit Nbits, then Xmin, Xmax, Ymin and Ymax as signed Nbits-bit values, padded to a whole byte. So the field is 9 bytes for a stage up to 1,638 pixels and grows with larger values, up to 17 bytes.
Flash writes a 550 × 400 pixel stage as these 9 bytes:
78 00 05 5F 00 00 0F A0 00
0x78is01111000: the first 5 bits,01111, give Nbits = 15.- The next 15 bits are Xmin = 0, then Xmax = 11,000 (550 px × 20), then Ymin = 0 and Ymax = 8,000 (400 px × 20).
- 5 + 4 × 15 = 65 bits, padded to 72: 9 bytes.
In the SWF 9 example the explorer reads a 9-byte FrameSize at offset 8 of the decompressed data: 0, 0 to 800, 600 pixels.
FrameRate
Frames a second, as 8.8 fixed point stored as a little-endian UI16: the first byte is
the fraction in 256ths, the second the whole number. 12 frames a second is
00 0C, 24 is 00 18, and the SWF 9 example’s 120 is
00 78. The fraction lets a movie run at, for example, 29.97 frames a
second (F8 1D).
FrameCount
The number of frames on the main timeline: the number of ShowFrame tags it holds.
Sprites have frame counts of their own, in their
DefineSprite tags. An
ActionScript 3 application often has one or two frames and builds everything else in
code. The tags follow at once; in the SWF 9 example the first tag is at offset
0x15 of the decompressed data.