Tuesday, March 24, 2009

The SWF header

All SWF files begin with the following header.



The header begins with a three-byte signature of either 0x46, 0x57, 0x53 (“FWS”); or 0x43,0x57, 0x53 (“CWS”). An FWS signature indicates an uncompressed SWF file; CWSindicates that the entire file after the first 8 bytes (that is, after the FileLength field) wascompressed by using the ZLIB open standard. The data format that the ZLIB library uses isdescribed by Request for Comments (RFCs) documents 1950 to 1952. CWS file compressionis permitted in SWF 6 or later only.

A one-byte version number follows the signature. The version number is not an ASCIIcharacter, but an 8-bit number. For example, for SWF 4, the version byte is 0x04, not theASCII character “4” (0x35).

The FileLength field is the total length of the SWF file, including the header. If this is anuncompressed SWF file (FWS signature), the FileLength field should exactly match the filesize. If this is a compressed SWF file (CWS signature), the FileLength field indicates the totallength of the file after decompression, and thus generally does not match the file size. Havingthe uncompressed size available can make the decompression process more efficient.

The FrameSize field defines the width and height of the on-screen display. This field is stored as a RECT structure, meaning that its size may vary according to the number of bits needed to encode the coordinates. The FrameSize RECT always has Xmin and Ymin value of 0; the Xmax and Ymax members define the width and height.

The FrameRate is the desired playback rate in frames per second. This rate is not guaranteed if, for example, Flash Player is running on a slow or busy CPU. The Frame Count is the total number of frames in this SWF file.

No comments:

Post a Comment