This section describes the basic data types used to define the more complex data structures that comprise the SWF file format.
Bit values are a linear sequences of bits that describe signed and unsigned integer and fixed point values. Other types of values that follow one or more bit values are always aligned to the nearest byte boundary with zero bits as padding.
Type | Comment |
SB[n] | Signed bit value - n is number of significant bits |
UB[n] | Unsigned bit value - n is number of significant bits |
FB[n] | Signed fixed-point bit value - n is number of significant bits The n bits are the lower n bits of a FIXED value. Just assign them to a 32 bit unsigned int value, and use the result as a FIXED. (LS 99.06.23) |
Integer values are 8-bit, 16-bit, and 32-bit signed and unsigned values.
Type | Comment |
SI8 | Signed 8-bit integer value |
SI16 | Signed 16-bit integer value |
SI32 | Signed 32-bit integer value |
SI8[n] | Signed 8-bit array - n is number of array elements |
SI16[n] | Signed 16-bit array - n is number of array elements |
UI8 | Unsigned 8-bit integer value |
UI16 | Unsigned 16-bit integer value |
UI32 | Unsigned 32-bit integer value |
UI8[n] | Unsigned 8-bit array - n is number of array elements |
UI16[n] | Unsigned 16-bit array - n is number of array elements |
UI32[n] | Unsigned 32-bit array - n is number of array elements |
Fixed values are a 32-bit signed fixed-point number (16.16).
Type | Comment |
FIXED | Signed 32-bit fixed-point number |
A color value represents a 24-bit red, green, and blue value.
Type | Comment |
RGB | Color value |
The format for a color value within the file is described in the following table:
Field | Type | Comment |
Red | UI8 | Red color value |
Green | UI8 | Green color value |
Blue | UI8 | Blue color value |
A ColorWithAlpha value represents a 32-bit red, green, and blue value with transparency information.
Type | Comment |
RGBA | Color value including alpha channel information |
The format for a color value within the file is described in the following table:
Field | Type | Comment |
Red | UI8 | Red color value |
Green | UI8 | Green color value |
Blue | UI8 | Blue color value |
Alpha | UI8 | Transparency color value |
A rectangle value represents a rectangular region defined by a minimum X- and Y-coordinate position with a maximum X- and Y-coordinate position.
Type | Comment |
RECT | Rectangular region |
The format for a rectangular value within the file is described in the following table:
Field | Type | Comment |
Nbits | nBits = UB[5] | Bits in each rect value field |
Xmin | SB[nBits] | X minimum position for rect |
Xmax | SB[nBits] | X maximum position for rect |
Ymin | SB[nBits] | Y minimum position for rect |
Ymax | SB[nBits] | Y maximum position for rect |
Type | Comment |
MATRIX | Transform matrix |
Field | Type | Comment |
HasScale | hasScale = UB[1] | Has scale values if equal to 1 |
NscaleBits | If hasScale nScaleBits = UB[5] | Bits in each scale value field |
ScaleX | If hasScale FB[nScaleBits] | X scale value |
ScaleY | If hasScale FB[nScaleBits] | Y scale value |
HasRotate | hasRotate = UB[1] | Has rotate and skew values if equal to 1 |
NrotateBits | If hasRotate nRotateBits = UB[5] | Bits in each rotate value field |
RotateSkew0 | If hasRotate FB[nRotateBits] | First rotate and skew value |
RotateSkew1 | If hasRotate FB[nRotateBits] | Second rotate and skew value |
NtranslateBits | nTranslateBits = UB[5] | Bits in each translate value field |
TranslateX | SB[nTranslateBits] | X translate value |
TranslateY | SB[nTranslateBits] | Y translate value |
Type | Comment |
CXFORM | Color transform |
Field | Type | Comment |
HasAddTerms | hasAdd = UB[1] | Has color addition values if equal to 1 |
HasMultTerms | hasMult = UB[1] | Has color multiply values if equal to 1 |
Nbits | nBits = UB[4] | Bits in each value field |
RedMultTerm | If hasMult SB[nBits] | Red multiply value |
GreenMultTerm | If hasMult SB[nBits] | Green multiply value |
BlueMultTerm | If hasMult SB[nBits] | Blue multiply value |
RedAddTerm | If hasAdd SB[nBits] | Red addition value |
GreenAddTerm | If hasAdd SB[nBits] | Green addition value |
BlueAddTerm | If hasAdd SB[nBits] | Blue addition value |
** The order of the bits HasMultTerms and HasAddTerms reversed. (PH 99.04.01). Confirmed (DM 99.07.07)
Type | Comment |
CXFORMWITHALPHA | Color transform |
Field | Type | Comment |
HasAddTerms | hasAdd = UB[1] | Has color addition values if equal to 1 |
HasMultTerms | hasMult = UB[1] | Has color multiply values if equal to 1 |
Nbits | nBits = UB[4] | Bits in each value field |
RedMultTerm | If hasMult SB[nBits] | Red multiply value |
GreenMultTerm | If hasMult SB[nBits] | Green multiply value |
BlueMultTerm | If hasMult SB[nBits] | Blue multiply value |
AlphaMultTerm | If hasMult SB[nBits] | Alpha multiply value |
RedAddTerm | If hasAdd SB[nBits] | Red addition value |
GreenAddTerm | If hasAdd SB[nBits] | Green addition value |
BlueAddTerm | If hasAdd SB[nBits] | Blue addition value |
AlphaAddTerm | If hasAdd SB[nBits] | Transparency addition value |
** The order of the bits HasMultTerms and HasAddTerms reversed. (PH 99.04.01). Confirmed (DM 99.07.07)
A string value represents a null terminated ASCII or multiple byte character string.
Type | Comment |
STRING | String value |
The format for a string value is a sequential list of bytes terminated by the null character byte.
Field | Type | Comment |
String | UI8[zero or more] | Non-null string character data |
StringEnd | UI8 | Marks end of string - always zero |
There are two categories of tags: definition and control. Definition tags manage a dictionary of resources such as shapes, text, bitmap, and buttons that can be used at any point in the animation. Control tags control the display list and enable actions such as stopping or starting the animation.
The following lists show the tags by category.
DefineShape | DefineShape2 | DefineShape3 | DefineMorphShape |
DefineBits | DefineBitsJPEG2 | DefineBitsJPEG3 | DefineBitsLossless |
DefineBitsLossless2 | JPEGTables | DefineButton | DefineButton2 |
DefineButtonCxform | DefineButtonSound | DefineFont | DefineFont2 |
DefineFontInfo | DefineText | DefineText2 | DefineSound |
SoundStreamBlock | SoundStreamHead | SoundStreamHead2 | DefineSprite |
End | FrameLabel | PlaceObject | PlaceObject2 |
Protect | RemoveObject | RemoveObject2 | SetBackgroundColor |
ShowFrame | StartSound | DoAction |
You use definition tags to create animation characters such as shapes, text, bitmap, and buttons. The following sections describe the data types and tags associated with each character type.
The following lists show the tags associated with each character.
DefineShape | DefineShape2 | DefineShape3 | DefineMorphShape |
DefineBits | DefineBitsJPEG2 | DefineBitsJPEG3 | DefineBitsLossless |
DefineBitsLossless2 | JPEGTables |
DefineButton | DefineButton2 | DefineButtonCxform | DefineButtonSound |
DefineFont | DefineFont2 | DefineFontInfo | DefineText |
DefineText2 |
DefineSound | SoundStreamBlock | SoundStreamHead | SoundStreamHead2 |
DefineSprite
Shapes in a SWF file have a flexible and powerful data structure that can be very efficiently rendered on the display. A shape is defined by the following elements:
In most PC vector graphics formats, shapes are defined by a path data structure that has fill and line styles and a series of curves or lines. SWF extends this format by allowing each curve in a shape to have
This flexible data structure is, in part, what enables SWF vectors to be small and rendered quickly. Note that filled shapes in a SWF file always use the even-odd fill rule.
SWF supports three basic types of fills for a shape.
A fill style array enumerates a number of fill styles.
Type | Comment |
FILLSTYLEARRAY | An array of fill styles |
The format of a fill style array is described in the following table:
Field | Type | Comment |
FillStyleCount | count = UI8 | Count of fill styles |
FillStyleCountExtended | If count = 0xFF count = UI16 | Extended count of fill styles. Supported only for Shape2 and Shape3. |
FillStyles | FILLSTYLE[count] | Array of fill styles |
A fill style represents how a close shape is filled in.
Type | Comment |
FILLSTYLE | A fill style value |
The format of a fill style value within the file is described in the following table:
Field | Type | Comment |
FillStyleType | type = UI8 0x00 = solid fill 0x10 = linear gradient fill 0x12 = radial gradient fill 0x40 = tiled bitmap fill 0x41 = clipped bitmap fill |
Type of fill style |
Color | If type = 0x00 RGBA (if Shape3); RGB (if Shape1 or Shape2) | Solid fill color with transparency information |
GradientMatrix | If type = 0x10 or 0x12 MATRIX | Matrix for gradient fill |
Gradient | If type = 0x10 or 0x12 GRADIENT | Gradient fill |
BitmapId | If type = 0x40 or 0x41 UI16 | ID of bitmap character for fill |
BitmapMatrix | If type = 0x40 or 0x41 MATRIX | Matrix for bitmap fill |
** For defining clipped bitmap filled shapes, 2 fillstyles
are used:
The first one has a FillStyleType of 0x41, a bitmap
id of 65535, and a matrix that defines the mapping of pixels on to the geomety.
The second fillstyle has a FillStyleType of 0x41,
the bitmap id of the image to use, and a matrix that is applied to the outline
geometry.
The first Fillstyle can be eliminated. It appears to be a bug in the authoring
tool. (PH 99.01.05)
Gradient information for a fill style.
Type | Comment |
GRADIENT | Gradient information |
The format of gradient information is described in the following table:
Field | Type | Comment |
NumGradients | nGrads = UI8 | 1 to 8 |
GradientRecords | GRADRECORD[nGrads] | Gradient records - see below |
Type | Comment |
GRADRECORD | Entry in a gradient record |
The gradient record format is:
Field | Type | Comment |
Ratio | UI8 | Ratio value |
Color | RGB (Shape1 or Shape2) RGBA (Shape3) |
Color of gradient |
A line style array enumerates a number of line styles.
Type | Comment |
LINESTYLEARRAY | An array of line styles |
The format of a line style array is described in the following table:
Field | Type | Comment |
LineStyleCount | count = UI8 | Count of line styles |
LineStyleCountExtended | If count = 0xFF count = UI16 | Extended count of line styles |
LineStyles | LINESTYLE[count] | Array of line styles |
A line style represents a width and color of a line.
Type | Comment |
LINESTYLE | A line style value |
The format of a line style value within the file is described in the following table:
Field | Type | Comment |
Width | UI16 | Width of line in twips |
Color | RGB (Shape1 or Shape2) RGBA (Shape3) |
Color value including alpha channel information for Shape3s |
Shape values define an open or closed shape without a fill style or line style record.
Type | Comment |
SHAPE | Shape information |
The format of shape style information is described in the following table:
Field | Type | Comment |
NumFillBits | NfillBits = UB[4] | Number of fill index bits |
NumLineBits | NlineBits = UB[4] | Number of line index bits |
ShapeRecords | SHAPEREC[one or more] | Shape records - see below |
A shape style record is the same as a shape except that a fill style and line style array is appended to the beginning of the data. These records are used in shape characters.
Type | Comment |
SHAPEWITHSTYLE | Shape with style information |
The format of shape style information is described in the following table:
Field | Type | Comment |
FillStyles | FILLSTYLEARRAY | Array of fill styles |
LineStyles | LINESTYLEARRAY | Array of line styles |
NumFillBits | nFillBits = UB[4] | Number of fill index bits |
NumLineBits | nLineBits = UB[4] | Number of line index bits |
ShapeRecords | SHAPEREC[one or more] | Shape records - see below |
There are three types of shape records.
Type | Comment |
SHAPERECORD | A shape record |
Shape Record Type 0 defines the end of shape record.
Field | Type | Comment |
TypeFlag | UB[1] = 0 | Non-edge record flag |
EndOfShape | UB[5] = 0 | End of shape flag |
Shape Record Type 1 defines changes in line style, fill style, position or a new set of styles.
Field | Type | Comment |
TypeFlag | UB[1] = 0 | Non-edge record flag |
StateNewStyles | newStyles = UB[1] | New styles flag. Used by DefineShape2 and DefineShape3 only. |
StateLineStyle | lineStyle = UB[1] | Line style change flag |
StateFillStyle1 | fillStyle1 = UB[1] | Fill style 1 change flag |
StateFillStyle0 | fillStyle0 = UB[1] | Fill style 0 change flag |
StateMoveTo | moveTo = UB[1] | Move to flag |
MoveBits | If moveTo nMoveBits = UB[5] | Move bit count |
MoveX | If moveTo SB[nMoveBits] | X value (relative to shape origin) |
MoveY | If moveToSB[nMoveBits] | Y value (relative to shape origin) |
Fill0Style | If fillStyle0 UB[nFillBits] | Fill 0 Style |
Fill1Style | If fillStyle1 UB[nFillBits] | Fill 1 Style |
LineStyle | If lineStyle UB[nLineBits] | Line Style |
FillStyles | If newStyles FILLSTYLEARRAY | Array of new fill styles |
LineStyles | If newStyles LINESTYLEARRAY | Array of new line styles |
NumFillBits | If newStyles UB[4] | Number of fill index bits for new styles |
NumLineBits | If newStyles UB[4] | Number of line index bits for new styles |
Shape Record Type 2 defines a straight or curved edge
Field | Type | Comment |
TypeFlag | UB[1] = 1 | This is an edge record |
EdgeRecord | EDGERECORD | Line or curve edge record |
There are two types of edge records.
Type | Comment |
EDGERECORD | An edge record |
Edge Record Type 0 - defines a curved edge
Field | Type | Comment |
EdgeFlag | UB[1] = 0 | Curved edge - always 0 |
NumBits | nBits = UB[4] + 2 | Number of bits per value |
ControlDeltaX | SB[nBits] | X control point change |
ControlDeltaY | SB[nBits] | Y control point change |
AnchorDeltaX | SB[nBits] | X anchor point change |
AnchorDeltaY | SB[nBits] | Y anchor point change |
Edge Record Type 1 - defines a straight edge
Field | Type | Comment |
EdgeFlag | UB[1] = 1 | Straight edge - always 1 |
NumBits | nBits = UB[4] + 2 | Number of bits per value |
GeneralLineFlag | lineFlag = UB[1] | General Line equals 1 |
DeltaX | If lineFlag = 1 SB[nBits] | X delta |
DeltaY | If lineFlag = 1 SB[nBits] | Y delta |
VertLineFlag | If lineFlag = 0 vertFlag = SB[1] | Vertical Line equals 1 |
DeltaX | If vertFlag = 0 SB[nBits] | X delta |
DeltaY | If vertFlag = 1 SB[nBits] | Y delta |
Defines a vector shape object. The shape definition is a run-length encoded list of bezier curve information, line styles, and fill styles. A shape can contain many different fill colors and line styles. This format compresses very well since each curve segment has its own fill and line attributes.
A mathematical gradient fill ability and the ability to fill an area with a bitmap enables rich graphics.(SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 2 |
ShapeId | UI16 | ID for this character |
ShapeBounds | RECT | Bounds of the shape |
Shapes | SHAPEWITHSTYLE | Shape information |
Extends the capabilities of DefineShape with the ability to support more than 255 styles in the style list and multiple style lists in a single shape. (SWF 2.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 22 |
ShapeId | UI16 | ID for this character |
ShapeBounds | RECT | Bounds of the shape |
Shapes | SHAPEWITHSTYLE | Shape information |
Extends the capabilities of DefineShape2 by extending all of the RGB color fields to support RGBA with alpha transparency. (SWF 3.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 32 |
ShapeId | UI16 | ID for this character |
ShapeBounds | RECT | Bounds of the shape |
Shapes | SHAPEWITHSTYLE | Shape information |
edge.curve.anchor.x=edge.line.x/2;
edge.curve.anchor.y=edge.line.y/2;
edge.curve.control.x=edge.line.x/2;
edge.curve.control.y=edge.line.y/2;
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 46 |
Character ID | UI16 | ID for this character |
ShapeBounds1 | RECT | Bounds of the original shape |
ShapeBounds2 | RECT | Bounds of the shape to which to morph |
Offset | DWORD | Indicates offset to Edges2 |
MorphFillStyles | MORPHFILLSTYLES | Fill style information is stored in the same manner as for a standard shape, however each fill consists of interleaved information based on a single style type to accommodate morphing. |
MorphLineStyles | MORPHLINESTYLES | Line style information is stored in the same manner as for a standard shape, however each line consists of interleaved information based on a single style type to accommodate morphing. |
Edges1 | Contains the set of edges and the style bits that indicate style changes (for example, MoveTo, FillStyle, and LineStyle.) Number of edges must equal the number of edges in Edges2. | |
Edges2 | Contains only the set of edges, with no style information. Number of edges must equal the number of edges in Edges1. |
A morph fill style array enumerates a number of fill styles.
Type | Comment |
MORPHFILLSTYLES | An array of fill styles |
The format of a fill style array is described in the following table:
Field | Type | Comment |
FillStyleCount | count = UI8 | Count of fill styles |
FillStyleCountExtended | If count = 0xFF count = UI16 | Extended count of fill styles. |
FillStyles | FILLSTYLE[count] | Array of fill styles |
A fill style represents how a close shape is filled in.
Type | Comment |
FILLSTYLE | A fill style value |
The format of a fill style value within the file is described in the following table:
Field | Type | Comment |
FillStyleType | type = UI8 0x00 = solid fill 0x10 = linear gradient fill 0x12 = radial gradient fill 0x41 = clipped bitmap fill |
Type of fill style |
Color1 | If type = 0x00 RGBA | Solid fill color with transparency information for first shape |
Color2 | If type = 0x00 RGBA | Solid fill color with transparency information for second shape |
GradientMatrix1 | If type = 0x10 or 0x12 MATRIX | Matrix for gradient fill for first shape |
GradientMatrix2 | If type = 0x10 or 0x12 MATRIX | Matrix for gradient fill for second shape |
Gradient | If type = 0x10 or 0x12 GRADIENT | Gradient fill |
BitmapId | If type = 0x40 or 0x41 UI16 | ID of bitmap character for fill |
BitmapMatrix1 | If type = 0x40 or 0x41 MATRIX | Matrix for bitmap fill for first shape |
BitmapMatrix2 | If type = 0x40 or 0x41 MATRIX | Matrix for bitmap fill for second shape |
Gradient information for a fill style.
Type | Comment |
GRADIENT | Gradient information |
The format of gradient information is described in the following table:
Field | Type | Comment |
NumGradients | nGrads = UI8 | 1 to 8 |
GradientRecords | GRADRECORD[nGrads] | Gradient records - see below |
Type | Comment |
GRADRECORD | Entry in a gradient record |
The gradient record format is:
Field | Type | Comment |
Ratio1 | UI8 | Ratio value for first shape |
Color1 | RGBA | Color of gradient for first shape |
Ratio2 | UI8 | Ratio value for second shape |
Color2 | RGBA | Color of gradient for second shape |
A morph line style array enumerates a number of fill styles.
Type | Comment |
MORPHLINESTYLES | An array of line styles |
The format of a line style array is described in the following table:
Field | Type | Comment |
LineStyleCount | count = UI8 | Count of line styles |
LineStyleCountExtended | If count = 0xFF count = UI16 | Extended count of line styles |
LineStyles | LINESTYLE[count] | Array of line styles |
A line style represents a width and color of a line. DefineMorphShape supports only solid line styles.
Type | Comment |
LINESTYLE | A line style value |
The format of a line style value within the file is described in the following table:
Field | Type | Comment |
Width1 | UI16 | Width of line in first shape in twips |
Width2 | UI16 | Width of line in second shape in twips |
Color1 | RGBA | Color value including alpha channel information for first shape |
Color2 | RGBA | Color value including alpha channel information for second shape |
SWF supports a variety of bitmap formats. One JPEG format has a JPEG header that is shared between multiple JPEG images in a single SWF file to minimize file size. Another JPEG format lets each image have it's own header, allowing each image its own compression settings. The zlib format is similar to an embedded PNG file and is used when you need lossless image compression. This is best for images that would compress well as a GIF file like screen shots or diagrams while JPEG is best for photographs.
Bitmaps in SWF can also contain alpha channel information. For lossless compression, there can be alpha channel information in a color table of an 8-bit image or there can be full alpha channel information for a 32-bit image. For JPEG images, alpha channels are stored using lossless zlib compression.
Note that when a bitmap in a SWF file is rendered, the full transform operation is applied to the image including the matrix transformation and the color transform operation.
Defines a bitmap character with JPEG compression. This tag contains only the JPEG compressed image data (as defined by the Independent JPEG Group). JPEGTables contains the JPEG encoding data used to encode this image. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 6 |
BitmapId | UI16 | ID for this character |
BitmapJPEGImage | UI8[image data size] | JPEG compressed image |
Defines a bitmap character with JPEG compression. This tag differs from DefineBits in that the record contains both the JPEG encoding table and the JPEG image data (as defined by the Independent JPEG Group). This record allows multiple JPEG images with differing compression ratios to be defined within a single SWF file.
Note: The JPEG encoding data and image data contained within this record are in two separate JPEG streams. Each JPEG stream has a beginning of stream tag (0xFF, 0xD8) and an end of stream tag (0xFF, 0xD9). This differs from a standard JPEG image which combines the encoding data and image data into a single stream. (SWF 2.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 21 |
BitmapId | UI16 | ID for this character |
BitmapJPEGEncoding | UI8[encoding data size] | JPEG encoding table |
BitmapJPEGImage | UI8[image data size] | JPEG compressed image |
Defines a bitmap character with JPEG compression. This tag differs from DefineBitsJPEG2 because it contains alpha channel data. This record allows multiple JPEG images with differing compression ratios to be defined within a single SWF file.
Note: The JPEG encoding data and image data contained within this record are in two separate JPEG streams. Each JPEG stream has a beginning of stream tag (0xFF, 0xD8) and an end of stream tag (0xFF, 0xD9). This differs from a standard JPEG image which combines the encoding data and image data into a single stream. (SWF 3.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 35 |
BitmapId | UI16 | ID for this character |
Offset | UI32 | Count of bytes in BitmapJPEGEncoding and BitmapJPEGImage (PH 99.05.12) |
BitmapJPEGEncoding | UI8[encoding data size] | JPEG encoding table |
BitmapJPEGImage | UI8[image data size] | JPEG compressed image |
BitmapAlphaData | UI8[alpha data size] | ZLIB compressed array of alpha data |
Defines a loss-less bitmap character that contains raw ZLIB compressed image data. The data format used by the ZLIB library is described by Request for Comments (RFCs) documents 1950 to 1952. (SWF 2.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 20 |
BitmapId | UI16 | Bitmap ID for this character |
BitmapFormat | bmFormat = UI8 | Format of compressed data 3 = 8 bit image data 4 = 16 bit image data 5 = 32 bit image data |
BitmapWidth | UI16 | Width of bitmap image |
BitmapHeight | UI16 | Height of bitmap image |
BitmapColorTableSize | if bmFormat == 3 U8(n-1) | Compressed color table size |
ColorTableRGB | RGB[color table size] | ZLIB compressed color data |
BitmapZLIBImage | UI8[image data size] | ZLIB compressed image data |
Defines a loss-less bitmap character that contains raw ZLIB compressed image data and alpha channel information. The data format used by the ZLIB library is described by Request for Comments (RFCs) documents 1950 to 1952. (SWF 3.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 36 |
BitmapId | UI16 | Bitmap ID for this character |
BitmapFormat | bmFormat = UI8 | Format of compressed data 3 = 8 bit image data 4 = 16 bit image data 5 = 32 bit image data |
BitmapWidth | UI16 | Width of bitmap image |
BitmapHeight | UI16 | Height of bitmap image |
BitmapColorTableSize | if bmFormat == 3 UI8(n-1) | Compressed color table size |
ColorTableRGBA | RGBA[color table size] | ZLIB compressed color data |
BitmapZLIBImage | UI8[image data size] | ZLIB compressed image data |
** Originally read if "bmFormat <= 3 UI8(n-1)", but bmFormat == 0, 1, 2 are undefined?
Defines the JPEG encoding table (as defined by the Independent JPEG Group) for the JPEG images defined using the DefineBits records. There should only be one record of this type in a SWF file. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 8 |
BitmapJPEGEncoding | UI8[encoding data size] | JPEG encoding table |
Button objects provide much of the interactivity in a SWF file. A button object consists of four states. The objects active in the first state are displayed when the button is idle. The objects in the second state are displayed when the mouse is over the button. The objects in the third state are displayed when the button is pressed by the mouse. The objects in the fourth state are used as a hit area to determine when the mouse is over the button. Buttons track the mouse in two ways: by push button and by menu button. Push buttons capture the mouse until the mouse button is released. Menu buttons do no capture the mouse.
Buttons can perform actions based on certain state transitions. The list of possible button state transitions are:
IdleToOverUpMouse enter up
OverUpToIdleMouse exit up
OverUpToOverDownMouse down
OverDownToOverUp Mouse up in
Push button transitions
These transitions only apply when tracking Push buttons:
OverDownToOutDownMouse exit down
OutDownToOverDownMouse enter down
OutDownToIdleMouse up out
Menu button transitions
These transitions only apply when tracking Menu buttons:
IdleToOverDownMouse enter down
OverDownToIdleMouse exit down
Typically button actions are performed on a OverDownToOverUp, but they can be performed on any state transition.
Defines a button character. A button is defined by an up image, mouse over image, depressed image and a hit region. There is also a list of actions to take when the button is clicked and released. See the DoAction tag. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 7 |
ButtonId | UI16 | ID for this character |
Buttons | BUTTONRECORD[one or more] | Button character records |
ButtonEndFlag | UI8 = 0 | Always set to 0 |
Actions | ACTIONRECORD[zero or more] | Actions to perform - see below |
ActionEndFlag | UI8 = 0 | Always set to 0 |
Button records describe the shape and text characters that comprise a button. Each character in a button must be associated with one or more states (up, down, over or hit test).
Type | Comment |
BUTTONRECORD | Contains data to describe characters in a button |
Field | Type | Comment |
ButtonReserved | UB[4] | Reserved bits - always 0 |
ButtonStateHitTest | UB[1] | Button state hit test flag |
ButtonStateDown | UB[1] | Button state down flag |
ButtonStateOver | UB[1] | Button state over flag |
ButtonStateUp | UB[1] | Button state up flag |
ButtonCharacter | UI16 | Button character ID |
ButtonLayer | UI16 | Button character layer |
ButtonMatrix | MATRIX | Button character matrix |
Defines a button character. A button is defined by an up image, mouse over image, depressed image, and a hit region. You can also specify color transformation and sound data. There is also a list of actions to take when the button is clicked and released. See the DoAction tag. (SWF 3.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 34 |
ButtonId | UI16 | ID for this character |
Flags | UI8 =0 or 1 | Track as menu flag |
Offset | UI16 | Offset to the first Button2ActionCondition (immediately following the BUTTONRECORDS) |
Buttons | BUTTONRECORD[one or more] | Button character records with color transform with alpha |
ButtonEndFlag | UI8 = 0 | Always set to 0 |
Button2ActionCondition | Specifies a series of actions to perform based on a condition. Each Button2ActionCondition consists of ActionOffset, Condition, Actions, and ActionEndFlag | |
ActionOffset | UI16 | Points to next Button2Action condition |
Condition | UI16 | Button state transitions triggering an action. UB[7] Reserved UB[1] OverDownToIdle UB[1] IdleToOverDown UB[1] OutDownToIdle UB[1] OutDownToOverDown UB[1] OverDownToOutDown UB[1] OverDownToOverUp UB[1] OverUpToOverDown UB[1] OverUpToIdle UB[1] IdleToOverUp |
Actions | ACTIONRECORD[zero or more] | Actions to perform - see the DoAction tag |
ActionEndFlag | UI8 = 0 | Always set to 0 |
** After the Flags field there is an Offset (UI16) to end of the Buttons. (PH 99.01.05)
** The ActionOffset preceeding the last Button2ActionCondition should be 0. (PH 99.01.05)
Button records describe the shape and text characters that comprise a button. Each character in a button must be associated with one or more states (up, down, over or hit test).
Type | Comment |
BUTTONRECORD | Contains data to describe characters in a button |
Field | Type | Comment |
ButtonReserved | UB[4] | Reserved bits - always 0 |
ButtonStateHitTest | UB[1] | Button state hit test flag |
ButtonStateDown | UB[1] | Button state down flag |
ButtonStateOver | UB[1] | Button state over flag |
ButtonStateUp | UB[1] | Button state up flag |
ButtonCharacter | UI16 | Button character ID |
ButtonLayer | UI16 | Button character layer |
ButtonMatrix | MATRIX | Button character matrix |
ColorTransform | CXFORM | Character color transform |
** There is only one ColorTransform in each button record, originally CXFORM[nCharacters in button]. (PH 99.05.01)
Defines the color transform for each shape and text character in a button. Not used for DefineButton2. (SWF 2.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 23 |
ButtonId | UI16 | Button ID for this information |
ButtonColorTransforms | CXFORM | Character color transform |
** There is only one ColorTransform in each button record, originally CXFORM[nCharacters in button]. (PH 99.01.05)
Defines the sound data for a button. (SWF 2.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 17 |
ButtonId | UI16 | Button ID this sound is for |
ButtonSoundChar | UI16 | Sound for state 0 |
ButtonSoundInfo | SOUNDINFO | Sound information for state 0 |
ButtonSoundChar | UI16 | Sound for state 1 |
ButtonSoundInfo | SOUNDINFO | Sound information for state 1 |
ButtonSoundChar | UI16 | Sound for state 2 |
ButtonSoundInfo | SOUNDINFO | Sound information for state 2 |
ButtonSoundChar | UI16 | Sound for state 3 |
ButtonSoundInfo | SOUNDINFO | Sound information for state 3 |
SWF defines an efficient font format. The font object defines the outlines of characters in a font. Only the characters that are actually used in the SWF file need to be stored in the font definition. Outlines are stored without any hinting information. (Since SWF graphics are normally anti-aliased, font quality is quite good without any hinting information.) Text objects in a SWF file consist of positioning information for each character to be placed and an index into a font object for the font outline.
The SWF font scheme has several advantages. The font definitions make it easy to reuse outlines, saving file size. These definitions also make it possible to use the font rendering engine of a platform (if that technique has advantages for a particular platform). Since the layout and positioning information is stored in the text object, it is possible to do very sophisticated text layout effects like kerning and text wrapping without having a complex layout engine built into a SWF file format player.
Defines the shape outlines that define each glyph used in a particular font. Only the glyphs that are used in a font are actually defined. This record consists of an offset table followed by a shape table. For each glyph in the shape table. the offset table stores the offset of the glyph in bytes from the start of the offset table. Also, there is a one-to-one ordering match between the order of the glyph offsets in the offset table and the order of the glyph shapes in the shape table. The number of glyphs in the shape table can be inferred by determining the offset of the first glyph shape and dividing the offset by two bytes for each offset entry. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 10 |
FontId | UI16 | ID for this character |
OffsetTable | UI16[nGlyphs] | Array of shape offsets |
ShapeTable | SHAPE[nGlyphs] | Array of shapes |
Defines the mapping from a font object to a device font so that the player can optionally use a TrueType or ATM font that may be installed on the computer instead of the stored glyph outlines. Also defines the shape outlines that define each glyph used in a particular font. This record consists of an offset table followed by a shape table; you have the option of extending the offset table to 32 bits. For each glyph in the shape table the offset table stores the offset of the glyph in bytes from the start of the offset table. Also, there is a one to one ordering match between the order of the glyph offsets in the offset table and the order of the glyph shapes in the shape table. (SWF 3.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 48 |
FontId | UI16 | Font ID for this information |
FontFlagsHasLayout* | UB[1] | Has font metrics/layout information |
FontFlagsShiftJIS | UB[1] | ShiftJIS encoding |
FontFlagsUnicode | UB[1] | Unicode encoding |
FontFlagsAnsi | UB[1] | ANSI encoding |
FontFlagsWideOffsets | UB[1] | If 1, uses 32 bit offsets |
FontFlagsWideCodes | UB[1] | If 1, font uses 16-bit codes, otherwise font uses 8 bit codes |
FontFlagsItalic | UB[1] | Italic Font |
FontFlagsBold | UB[1] | Bold Font |
FontFlagsReserved ** | UB[8] | Reserved Flags |
FontNameLen | UI8 | Length of name |
FontName | UI8[NameLen] | Name of Font |
FontGlyphCount | UI16 | Count of Glyphs in font – nGlyphs |
FontOffsetTable | If FontFlagsWideOffsets is 1, UI32[nGlyphs] else UI16[nGlyphs] | |
FontShapeTable | SHAPE[nGlyphs] | |
FontCodeTable | If FontFlagsWideCodes is 1, UI16[nGlyphs] else UI8[nGlyphs] | |
FontAscent | If FontFlagsHasLayout is 1, SI16 - Font ascender height |
|
FontDescent | If FontFlagsHasLayout is 1, SI16 - Font decender height |
|
FontLeading | If FontFlagsHasLayout is 1, SI16 - Font leading height |
|
FontAdvanceTable | If FontFlagsHasLayout is 1, SI16[nGlyphs] |
|
FontBoundsTable | If FontFlagsHasLayout = 1, RECT[nGlyphs] |
|
FontKerningCount | If FontFlagsHasLayout is 1, UI16 - Font kerning table count |
*If FontFlagsHasLayout has been set, each kerning structure has the following data:
FontKerningCode1. If FontFlagsWideCodes is 1, UI16 else UI8.
FontKerningCode2. If FontFlagsWideCodes is 1, UI16 else UI8.
FontKerningAdjustment. SI16
** In the original SWF reference the FontFlagsReserved field came before the FontFlags, which was not true to the actual file format. (JW 99.04.19)
Comment from PH about DefineFont2:
FontGlyphCount - gives the count of glyphs in the font - nGlyphs.
This is followed by FontOffsetTable[nGlyphs] then SHAPE[nGlyphs].
In a file I was decoding I received the value nGlyphs = 224 , then the first
offset value in the FontOffsetTable as 450 ( U16 ) . This implies that the the
font offset table is 450 bytes long, and that there are 450 / 2 or 225 glyphs..
I have treated it as if there is 2 bytes of padding at the end of the fontOffsetTable
and the SHAPE table. Maybe I am parsing the DefineFont2 tag incorrectly, although
I have been through the code countless times and it seems right.
Defines the mapping from a font object to a device font so that the player can optionally use a TrueType or ATM font that may be installed on the computer instead of the stored glyph outlines. This record also contains information that can be used to map glyph indices in a text record to character codes to reconstruct the original string data. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 13 |
FontId | UI16 | Font ID this information is for |
FontNameLen | nameLen = UI8 | Length of font name |
FontName | UI8[nameLen] | Name of the font |
FontFlagsReserved | UB[2] | Reserved bit fields |
FontFlagsUnicode | UB[1] | Unicode character codes |
FontFlagsShiftJIS | UB[1] | ShiftJIS character codes |
FontFlagsANSI | UB[1] | ANSI character codes |
FontFlagsItalic | UB[1] | Font is italic |
FontFlagsBold | UB[1] | Font is bold |
FontFlagsWideCodes | wideChars = UB[1] | if 1 codeTable is UI16s else UI8s |
CodeTable | if wideChars = 1 U16[nGlyphs] if wideChars = 0 UI8[nGlyphs] |
Glyph to code table |
Defines a text object. This is a complex record that describes the font, height, color, and position of every text character in the record. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 11 |
TextId | UI16 | ID for this character |
TextBounds | RECT | Bounds of the text |
TextMatrix | MATRIX | Matrix for the text |
TextGlyphBits | NGlyphBits = UI8 | Bits in each glyph index |
TextAdvanceBits | NAdvanceBits = UI8 | Bits in each advance value |
TextRecords | TEXTRECORD[zero or more] | Text records |
TextEndOfRecordsFlag | UI8 = 0 | Always set to zero |
Text records specify either changes to the state of text or actual glyph indices for text.
Type | Comment |
TEXTRECORD | A text record type 0 or type 1 as specified below |
Field | Type | Comment |
TextRecordType | UB[1] = 0 | 0 if text glyph record |
TextGlyphCount | NGlyphs = UB[7] | Number of glyphs in record |
TextGlyphEntries | GLYPHENTRY[nGlyphs] | Glyph entry - see below |
Field | Type | Comment |
TextRecordType | UB[1] = 1 | 1 if text state change record |
TextReserved | UB[3] | Reserved - always 0 |
TextHasFont | HasFont = UB[1] | 1 if text font specified |
TextHasColor | HasColor = UB[1] | 1 if text color specified |
TextHasYOffset | HasYOffset = UB[1] | 1 if Y offset specified |
TextHasXOffset | HasXOffset = UB[1] | 1 if X offset specified |
TextFont | If hasFont UI16 | Font ID for following text |
TextColor | If hasColor RGB | Font color for following text |
TextXOffset | If hasXOffset SI16 | Font X offset for following text |
TextYOffset | If hasYOffset SI16 | Font Y offset for following text |
TextHeight | If hasFont UI16 | Font height for following text |
** The Type for TextRecordType changed to read UB[1]=1 instead of UB[1]=0. (PH 99.04.01)
** The fields TextXOffset and TextYOffset changed to SI16 instead of UI16. (PH 99.04.01)
Glyph entries describe the glyph index and X advance value to use for a particular character in the currently selected font for the text record.
Type | Comment |
GLYPHENTRY | A glyph entry that describes a text glyph |
Field | Type | Comment |
TextGlyphIndex | UB[nGlyphBits] | Glyph index into current font |
TextGlyphAdvance | SB[nAdvanceBits] | X advance value for glyph |
Defines a text object with color transparency data. This is a complex record that describes the font, height, color, and position of every text character in the record. (SWF 3.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 33 |
TextId | UI16 | ID for this character |
TextBounds | RECT | Bounds of the text |
TextMatrix | MATRIX | Matrix for the text |
TextGlyphBits | NGlyphBits = UI8 | Bits in each glyph index |
TextAdvanceBits | NadvanceBits = UI8 | Bits in each advance value |
TextRecords | TEXTRECORD[zero or more] | Text records |
TextEndOfRecordsFlag | UI8 = 0 | Always set to zero |
Text records specify either changes to the state of text or actual glyph indices for text.
Type | Comment |
TEXTRECORD | A text record type 0 or type 1 as specified below |
Field | Type | Comment |
TextRecordType | UB[1] = 0 | 0 if text glyph record |
TextGlyphCount | NGlyphs = UB[7] | Number of glyphs in record |
TextGlyphEntries | GLYPHENTRY[nGlyphs] | Glyph entry - see below |
Field | Type | Comment |
TextRecordType | UB[1] = 0 | 1 if text state change record |
TextReserved | UB[3] | Reserved - always 0 |
TextHasFont | HasFont = UB[1] | 1 if text font specified |
TextHasColor | HasColor = UB[1] | 1 if text color specified |
TextHasYOffset | HasYOffset = UB[1] | 1 if Y offset specified |
TextHasXOffset | HasXOffset = UB[1] | 1 if X offset specified |
TextFont | If hasFont UI16 | Font ID for following text |
TextColor | If hasColor RGBA | Font color for following text |
TextXOffset | If hasXOffset UI16 | Font X offset for following text |
TextYOffset | If hasYOffset UI16 | Font Y offset for following text |
TextHeight | If hasFont UI16 | Font height for following text |
Glyph entries describe the glyph index and X advance value to use for a particular character in the currently selected font for the text record.
Type | Comment |
GLYPHENTRY | A glyph entry that describes a text glyph |
Field | Type | Comment |
TextGlyphIndex | UB[nGlyphBits] | Glyph index into current font |
TextGlyphAdvance | SB[nAdvanceBits] | X advance value for glyph |
The SWF file format defines a small and efficient sound model. Sounds are stored as 2-, 3-, 4- or 5-bit ADPCM. This simple but efficient compression scheme avoids any licensing or patent issues that arise with more sophisticated sound compression schemes and helps to keep player implementations very small. SWF supports sample rates of 5.5, 11, 22 and 44 khz in both stereo and mono. It is assumed that the playback platform can support rate conversion and multi-channel mixing of these sounds.
The number of simultaneous channels supported depends on the CPU of specific platforms, but is typically three to eight channels. There is also the concept of a sound envelope where a simple transform can be applied to a sound object to generate various types of fades and level control (fade-in, fade-out, cross-fade).
Sounds in SWF are stored as individual sound objects that can be reused and mixed at runtime. The SWF file format also supports a streaming sound mode where sound data is played and downloaded in tight synchronization with the timeline. In this mode, sound packets are stored with each frame. If a CPU cannot render the frames of a movie as quickly as specified by the frame rate of the movie, the player slows down the animation rate instead of skipping frames. When streaming sound is present, the player skips frames in order to maintain tight synchronization with the sound track.
Note that a timeline can only have a single streaming sound playing at a time, but each movie clip can have it's own streaming sound.
See Also: StartSound
Sound information modifies how a sound character is played.
Type | Comment |
SOUNDINFO | Sound information |
The format of sound information is described in the following table:
Field | Type | Comment |
SyncFlags | UB[4] |
Sync flags 0x1 = syncNoMultiple Don't start the sound if already playing. 0x2 = SyncStop Stop the sound. |
HasEnvelope | hasEnvelope = UB[1] | Has envelope information if equal to 1 |
HasLoops | hasLoops = UB[1] | Has loop information if equal to 1 |
HasOutPoint | hasOutPoint = UB[1] | Has out point information if equal to 1 |
HasInPoint | hasInPoint = UB[1] | Has in point information if equal to 1 |
InPoint | if hasInPoint UI32 | Sound in point value |
OutPoint | if hasOutPoint UI32 | Sound out point value |
LoopCount | if hasLoops UI16 | Sound loop count |
EnvelopeNumPoint | if hasEnvelope nPoints = UI8 | Sound Envelope point count |
EnvelopeRecords | if hasEnvelope SNDENV[nPoints] | Sound Envelope records |
** The 4 SyncFlags bits moved to before the the HasEnvelope
bits, instead of after the HasInPoint bit. (PH 99.04.01)
Type | Comment |
SNDENV | Sound envelope information record |
The sound envelope record format is
Field | Type | Comment |
Mark44 | UI32 | Mark44 information |
Level0 | UI16 | Level 0 information |
Level1 | UI16 | Level 1 information |
Defines the data for a sound. (SWF 2.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 14 |
SoundId | UI16 | ID for this character |
SoundFormat | UB[4] 0 = sndCompressNone 1 = sndCompressADPCM |
Format of sound. Level of compression is stored in the ADPCM data. |
SoundRate | UB[2] 0 = snd5K 1 = snd11K 2 = snd22K 3 = snd44K |
Sound rate |
SoundSize | UB[1] 0 = snd8Bit 1 = snd16Bit |
Size of sound data |
SoundType | UB[1] 0 = sndMono 1 = sndStereo |
Mono or stereo sound |
SoundSampleCount | UI32 | Number of samples |
SoundData | UI8[size of compressed data] | Compressed sound data |
Defines sound data that is interleaved with frame data so that sounds can be played as the movie is streamed over a network connection. (SWF 2.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 19 |
StreamSoundData | UI8[size of compressed data] | Compressed sound data |
Defines the start of sound data that is interleaved with frame data so that sounds can be played as the movie is streamed over a network connection. Does not support uncompressed sound. (SWF 2.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 18 |
StreamSoundMixFormat | U8 | Recommended mixer format |
StreamSoundFormat | UB[4] = 1 | Always ADPCM |
StreamSoundReserved | UB[2] | Always zero |
StreamSoundSize | UB[1] = 1 | Always 16 bit |
StreamSoundType | UB[1] 0 = sndMono 1 = sndStereo |
Mono or stereo sound |
StreamSoundSampleCount | UI16 | Number of samples |
Defines the start of sound data that is interleaved with frame data so that sounds can be played as the movie is streamed over a network connection. Supports uncompressed sound. (SWF 3.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 45 |
StreamSoundMixFormat | U8 | Recommended mixer format |
StreamSoundCompression | UB[4] | 1 = Compressed ADPCM |
StreamSoundReserved | UB[2] | Always zero |
StreamSoundSize | UB[1] | If StreamSoundCompression = 1, always 16-bit. If StreamSoundCompression = 0, 8- or 16-bit. |
StreamSoundType | UB[1] 0 = sndMono 1 = sndStereo |
Mono or stereo sound |
StreamSoundSampleCount | UI16 | Number of samples |
SWF sprites (movie clips) are a SWF movie contained within a SWF movie. A sprite tag consists of a series of control tags. All the definition tags should be defined in the main body of the file before the sprite is defined. When a sprite is placed on the display list, it starts a new thread of control where the frames of the sprite are processed independently of the current main timeline frame. A sprite is stopped when it is removed from the display list. The objects placed by a sprite are added to the display list as children of the sprite object. The sprite transform is concatenated to the object transforms.
Defines a sprite. (SWF 3.0). Sprites are a grouped series of tags. They allow you to nest tags. Each sprite has an independent timeline.
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 39 |
Sprite ID | UI16 | ID of sprite |
Frame Count | UI16 | Total number of frames in sprite |
...<mini file structure>... | A series of tags |
** The frame count (UI16) between SpriteID and <mini file structure> was missing in the original spec (MS 99.07.12)
The valid tags within a sprite are as follows:
ShowFrame
PlaceObject
PlaceObject2
RemoveObject
RemoveObject2
DoAction
StartSound
FrameLabel
SoundStreamHead
SoundStreamBlock
End
Control tags can be divided into three categories: display list, control, and action. The following sections describe each category and its tags.
PlaceObject | PlaceObject2 | RemoveObject | RemoveObject2 |
ShowFrame |
End | Protect | FrameLabel | SetBackgroundColor |
StartSound |
DoAction
Display list tags control the contents of the display list. (See the Display List section for more information on the display list.) The following tags are display list:
PlaceObject and PlaceObject2Place the specified object on the display list.
RemoveObject and RemoveObject2Remove the specified object from the display list.
ShowFrameDisplays the display list contents on screen.
Places the indicated character on the display surface with an arbitrary PostScript style transformation matrix. Also includes a depth parameter to indicate a stacking order. Each character can be placed many times on the screen. If the length of the record indicates a size that exceeds the end of the transformation matrix, it is assumed that color transformation data is appended to the record. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 4 |
CharacterId | UI16 | ID of character to place |
Depth | UI16 | Depth of character |
Matrix | MATRIX | Transform matrix data |
ColorTransform (optional) | CXFORM | Color transform data |
Places the indicated character on the display surface with an arbitrary PostScript style transformation matrix. Also includes a depth parameter to indicate a stacking order. Each character can be placed many times on the screen. (SWF 3.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 26 |
PlaceFlagsReserved | UB[2] | Reserved Flags (undocumented). These might control clipping (PH 99.04.01) |
PlaceFlagHasName | UB[1] | Has name |
PlaceFlagHasRatio | UB[1] | Has ratio |
PlaceFlagHasColorTransform | UB[1] | Has color transform |
PlaceFlagHasMatrix | UB[1] | Has matrix |
PlaceFlagHasCharacter | UB[1] | Places a character |
PlaceFlagMove | UB[1] | Transforms a character that has already been placed.  Typically, an animated object has PlaceFlagHasCharacter set in the first frame, and PlaceFlagMove set in subsequent frames, with new color or transform matrices. (DM 99.07.13) |
Depth | UI16 | Depth of character |
CharacterId | If PlaceFlagHasCharacter = 1 UI16 | ID of character to place |
Matrix | If PlaceFlagHasMatrix = 1 MATRIX | Transform matrix data |
ColorTransform | If PlaceFlagHasColorTransform = 1 CXFORM | Color transform data |
Ratio | If PlaceFlagHasRatio = 1 UI16 | Used in tweening. Indicates the amount of target shape
in an intermediate tween shape. Ratio ranges in value between 0
(at the frame associated with the source shape) and less than 65536
(at the last tween frame) and reflects the amount of easing in and out.  (RH 99.05.14) The ratio field is used in conjunction with the MOVE flag to control MorphShape's. Each MorphShape has to sets of edges (edges1 and edges2). When a PlaceObject2 is used on a MorphShape with the MOVE and HasRatio flags set, the ratio says how far along a linear interpolation between edges1 and edges2 the shape is. ratio=0 means just display the edges1 shape, ratio=65535 means just display the edges2 shape.  (CG 99.07.15) |
Name | If PlaceFlagHasName = 1 STRING | Name of character |
Removes the indicated character from the display surface. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 5 |
CharacterId | UI16 | ID of character to remove |
Depth | UI16 | Depth of character |
Removes the character from the display surface. (SWF 3.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 28 |
Depth | UI16 | Depth of character |
Flags the end of the current frame. During playback, the characters present in the display list (see PlaceObject/RemoveObject) should be rendered and movie paused for the duration of a single frame. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 1 |
Control tags manage some overall aspects of files and frames. The following tags are control tags:
SetBackgroundColorSets the background color displayed in the frame.
FrameLabelLabels a frame for your easy reference.
ProtectMarks the file so that it cannot be opened in the authoring system.
StartSoundStarts and stops a sound.
EndMarks the end of the SWF file.
Set the background color of the display. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 9 |
BackgroundColor | COLOR | Color of the movie background |
Names a frame. (SWF 3.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 43 |
String | Null-terminated STRING. (0 is NULL) | Label for frame.. |
Marks a file as not importable for editing in the authoring tool. If this tag is present in the file, the authoring tool should prevent loading of the file for editing. (SWF 2.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 24 |
Starts playing a sound character. You can stop a sound by setting the synchStop flag in the SoundInfo structure used by DefineSound. (SWF 2.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 15 |
SoundId | UI16 | ID of sound character to play |
SoundInfo | SOUNDINFO | Sound information |
Marks the end of a file. This should always be the last tag in a file. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 0 |
The SWF File format defines a simple action model. An action list can be attached to a button state transition or placed in the tags that will be processed for a given frame. There are 127 possible actions of which 13 are currently defined. An action list consists of an 1-byte action code. If the high bit of the action code is set, then there is a 16 bit length that describes the amount of data used by the action. If the high bit is clear, the action has no data.
When an action is encountered, it is added to a list to be processed. The list is processed on a ShowFrame tag or after a button state has changed. An action can cause other actions to be triggered, in which case, the action is added to the list of actions to be processed. Actions are processed until the action list is empty.
Actions such as stop, play and go to frame apply to a particular timeline. By default, they apply to the timeline which contains them. However, the SetTarget action (tell target) can be used to send an action to another timeline.
Action values specify an action the player should perform when the frame is complete, when a button is pressed, or when a do action tag is encountered.
Type | Comment |
ACTIONRECORD | An action value as specified below |
Field | Type | Comment |
ActionGotoFrame | UI8 | Action = 0x81 |
Length | UI16 | Always 2 |
Frame | UI16 | Frame index |
Field | Type | Comment |
ActionGetURL | UI8 | Action = 0x83 |
Length | UI16 | Combined length of strings |
UrlString | STRING | Target URL string |
WinString | STRING | Target window string |
** The special significance of the targets _level1,
_level0 should be described.
Also the effect of giving a zero length URL and a target of _level1 should be
documented. (PH 99.01.10)
Field | Type | Comment |
ActionNextFrame | UI8 | Action = 0x04 |
Field | Type | Comment |
ActionPrevFrame | UI8 | Action = 0x05 |
Field | Type | Comment |
ActionPlay | UI8 | Action = 0x06 |
Field | Type | Comment |
ActionStop | UI8 | Action = 0x07 |
Field | Type | Comment |
ActionToggleQualty | UI8 | Action = 0x08 |
Field | Type | Comment |
ActionStopSounds | UI8 | Action = 0x09 |
Field | Type | Comment |
ActionWaitForFrame | UI8 | Action = 0x8A |
Length | UI16 | Always 3 |
Frame | UI16 | Frame to wait for |
SkipCount | UI8 | Number of actions to skip if frame is not loaded |
Field | Type | Comment |
ActionSetTarget | UI8 | Action = 0x8B |
Length | UI16 | All Action codes with high bit set (i.e. Action >= 0x80) have a U16 length (DM 99.07.13) |
TargetName | STRING | Target of action target |
Field | Type | Comment |
ActionGoToLabel | UI8 | Action = 0x8C |
Length | UI16 | All Action codes with high bit set (i.e. Action >= 0x80) have a U16 length (DM 99.07.13) |
Label | STRING | Frame label |
Flags that the specified actions should be performed when the frame is complete. (SWF 1.0)
Field | Type | Comment |
Header | RECORDHEADER | Tag ID = 12 |
Actions | ACTIONRECORD[zero or more] | Actions to perform - see below |
ActionEndFlag | UI8 = 0 | Always set to 0 |