Field | Type | Comment |
Signature | UI8 | Signature byte 1 - always 'F' |
Signature | UI8 | Signature byte 2 - always 'W' |
Signature | UI8 | Signature byte 3 - always 'S' |
Version | UI8 | Single byte file version |
File Length | UI32 | Length of entire file in bytes |
Frame Size | RECT | Frame size in TWIPS |
Frame Rate | UI16 | Frame delay in 8.8 fixed number of frames per second |
Frame Count | UI16 | Total number of frames in movie |
Following the header are a series of tagged data blocks. Each data block has a tag type (stag) and a length. There is both a short and long tag format. Short tags are used for blocks with 62 bytes of data or less and large tags can be used for any size block. A short tag has 9 bits used for the block type and 6 bits used for a block length in number of bytes. If a block is 63 bytes or longer, it should be stored in a long tag which consists of a short tag whose length is 0x3f and is followed by a 32-bit length.
The following tables show the structure of both short and long tag record headers.
Field | Type | Comment |
Tag | UB[10] | Tag id |
Length | UB[6] | Length of tag |
** The short header is not a 10 bit field with the tag followed by a 6 bit length. it is actually a 16 bit word with the high order 10 bits having the tag and the low order 6 bits having the length. (PH)
Field | Type | Comment |
Tag | UB[10] | Tag id |
Long Header Flag | UB[6] | Always 0x3F |
Length | UI32 | Length of tag |
** The long header does not start with 10 bit field with the tag followed by a 6 bit value 0x3f. it is actually a 16 bit word with the high order 10 bits having the tag and the low order 6 bits having the value 0x3f. (PH 99.01.04)
Any program parsing a SWF file can skip over blocks it does not understand. Data blocks can point to offsets within the block, but they should never point to an offset in another block. This enables tags to be removed, inserted, or modified by tools that process a SWF file. With some network transports like RealFlash, data blocks can be reordered and delivered with different priorities.
Currently, many useful block types are defined. Tag numbers 0-511 are
reserved for future use. Tag numbers 512-1023 are reserved for use by third
party applications. For more information on developing extension mechanisms,
see the extension mechanism section.
This ordering of tags is how the SWF file format supports streaming. The rule is that a given tag should only depend on tags that come before it. A tag should never depend on a tag that comes later in the file.
The End tag should be used at the end of the file to indicate the file's
end.
Characters are entered into the dictionary when a define tag is encountered
in the .swf file. Characters are looked up in the dictionary based on the
character identification number.
In SWF 1 and 2, the display list was a flat list of the objects that are present on the screen at any given point in time. For SWF 3, this list has been extended to a hierarchical list where an element on the display can have a list of child elements.
Objects on the display list are referred to by a depth number. The object at depth 0 is the bottom of the stacking order. Only one object can exist at any given depth.
There are three basic operations on the display list:
** TWIP: The term TWIP should be defined more clearly
somewhere. A TWIP seems to be 1/20 of a pixel. (PH 99.01.04)
Color Transforms—SWF uses color transforms to perform effects like fading in or out from an object on the display. The color transform consists of a simple linear equation that is applied to each color element of an object.
Ratio—For some objects like morphed shapes, a 16-bit ratio is used to control what point in the morph should be displayed. The ratio is also used to track the lifetime of sprite objects.
Clip depth—An object on the SWF display list can be used as a
clipping path for range of objects. This is controlled by the clip depth
field for Place object.
A SWF file is divided into numbered frames by ShowFrame tags. Frame
1 is defined by performing all the control operations before the first
ShowFrame tag. Frame 2 is defined by performing all the control operations
before the second ShowFrame tag and so on.
<company name>/<extension set>For the entire file, these tag types will be interpreted in the context of the named extension. Applications should be able to remap the tag range for a particular file to avoid conflicts between two extension sets.
The extension must be in the 512-1023 tag type range.
***** Dumping SWF File Information ***** ----- Reading the file header ----- FWS File version 3 File size 741 Movie width 550 Movie height 400 Frame rate 12 Frame count 10The file header shows much information. FWS indicates that the file is a SWF file; its version is 3.0 file. The file size is 741 bytes. The movie width is 550; its height is 400 pixels. The frame rate is 12 frames per second; there are ten frames in this movie.
----- Reading movie details ----- <----- dumping frame 0 file offset 21 ----->The offset of Frame 0 is 21 bytes into the file.
tagLen 3: tagSetBackgroundColor RGB_HEX ffffffTagLen specifies the actual length of the tag, in this case, 3 bytes (ffffff). .This tagSetBackgroundColor sets the background color to white.
tagLen 2: tagDoAction action code 7 stop action code 0Pauses the frame. (DoAction's action is Stop. Action code 0 means that there are no more actions.)
tagLen 32: tagDefineShape tagid 1Defines the first shape.
tagLen 10: tagPlaceObject2 flags 1 depth 26 tag 1 pos matrix hex [ a_fixed b_fixed] = [00010000 00000000] [ c_fixed d_fixed] [00000000 00010000] [tx_fixed ty_fixed] [000010a4 00000410]Inserts the first shape (tag 1) on the display list. The object's position on the stage is defined by the matrix.
tagLen 201: tagDefineShape2 tagid 2 tagLen 76: tagDefineShape tagid 3 tagLen 190: tagDefineShape2 tagid 4 tagLen 33: tagDefineButton2 tagid 5Defines more shapes and a button.
tagLen 15: tagPlaceObject2 flags 2 depth 26 tag 5 pos matrix hex [ a_fixed b_fixed] = [0004dbd3 00000000] [ c_fixed d_fixed] [00000000 0004dbd3] [tx_fixed ty_fixed] [00000600 00000a1c]Inserts the button (tag 5) on display list.
tagLen 0: tagShowFrameDisplays contents of display list on the screen.
<----- dumping frame 1 file offset 627 -----> tagLen 2: tagRemoveObject2 depth 2Removes button from the display list.
tagLen 8: tagPlaceObject2 flags 1 depth 26 pos matrix hex [ a_fixed b_fixed] = [00010000 00000000] [ c_fixed d_fixed] [00000000 00010000] [tx_fixed ty_fixed] [000012ea 00000690]Moves square left to right, top to bottom, diagonally on the stage.
tagLen 0: tagShowFrameDisplays display list contents on the screen.
<----- dumping frame 2 file offset 643 -----> tagLen 8: tagPlaceObject2 flags 1 depth 26 pos matrix hex [ a_fixed b_fixed] = [00010000 00000000] [ c_fixed d_fixed] [00000000 00010000] [tx_fixed ty_fixed] [00001530 00000910]Moves square left to right, top to bottom, diagonally on the stage.
tagLen 0: tagShowFrameDisplays contents of display list on the screen.
<----- dumping frame 3 file offset 655 -----> tagLen 8: tagPlaceObject2 flags 1 depth 26 pos matrix hex [ a_fixed b_fixed] = [00010000 00000000] [ c_fixed d_fixed] [00000000 00010000] [tx_fixed ty_fixed] [00001776 00000b90]Moves square left to right, top to bottom, diagonally on the stage.
tagLen 0: tagShowFrameDisplays contents of display list on the screen.
<----- dumping frame 4 file offset 667 -----> tagLen 8: tagPlaceObject2 flags 1 depth 26 pos matrix hex [ a_fixed b_fixed] = [00010000 00000000] [ c_fixed d_fixed] [00000000 00010000] [tx_fixed ty_fixed] [000019bc 00000e10]Moves square left to right, top to bottom, diagonally on the stage.
tagLen 0: tagShowFrameDisplays contents of display list on the screen.
<----- dumping frame 5 file offset 679 -----> tagLen 8: tagPlaceObject2 flags 1 depth 26 pos matrix hex [ a_fixed b_fixed] = [00010000 00000000] [ c_fixed d_fixed] [00000000 00010000] [tx_fixed ty_fixed] [00001c03 00001090]Moves square left to right, top to bottom, diagonally on the stage.
tagLen 0: tagShowFrameDisplays contents of display list on the screen.
<----- dumping frame 6 file offset 691 -----> tagLen 8: tagPlaceObject2 flags 1 depth 26 pos matrix hex [ a_fixed b_fixed] = [00010000 00000000] [ c_fixed d_fixed] [00000000 00010000] [tx_fixed ty_fixed] [00001e49 00001310]Moves square left to right, top to bottom, diagonally on the stage.
tagLen 0: tagShowFrameDisplays contents of display list on the screen.
<----- dumping frame 7 file offset 703 -----> tagLen 8: tagPlaceObject2 flags 1 depth 26 pos matrix hex [ a_fixed b_fixed] = [00010000 00000000] [ c_fixed d_fixed] [00000000 00010000] [tx_fixed ty_fixed] [0000208f 00001590]Moves square left to right, top to bottom, diagonally on the stage.
tagLen 0: tagShowFrameDisplays contents of display list on the screen.
<----- dumping frame 8 file offset 715 -----> tagLen 8: tagPlaceObject2 flags 1 depth 26 pos matrix hex [ a_fixed b_fixed] = [00010000 00000000] [ c_fixed d_fixed] [00000000 00010000] [tx_fixed ty_fixed] [000022d5 00001810]Moves square left to right, top to bottom, diagonally on the stage.
tagLen 0: tagShowFrameDisplays contents of display list on the screen.
<----- dumping frame 9 file offset 727 -----> tagLen 8: tagPlaceObject2 flags 1 depth 26 pos matrix hex [ a_fixed b_fixed] = [00010000 00000000] [ c_fixed d_fixed] [00000000 00010000] [tx_fixed ty_fixed] [0000251b 00001a90]Moves square left to right, top to bottom, diagonally on the stage.
tagLen 0: tagShowFrameDisplays contents of display list on the screen.
<----- dumping frame 10 file offset 739 -----> tagLen 0: tagEndtagEnd indicates the end of the file.
***** Finished Dumping SWF File Information *****