SWF Tags

The following table is a list of all the SWF tags defined in this documentation.

This table presents the tags sorted using their number. There are tables available to find tags by name, by version of Flash releases, and by type.

IDsort icon Tag Name Type Comments Version
-1. File Header Format

Although it isn't a tag per say, we consider the file header as being a tag because it represents a block in the flash file. Since version 8, it can be complemented by the FileAttributes tag.

1
End Format

Mark the end of the file or a Sprite. It can't appear anywhere else but the end of the file or a Sprite.

1
1. ShowFrame Display

Display the current display list and pauses for 1 frame as defined in the file header.

1
2. DefineShape Define

Define a simple geometric shape.

1
3. FreeCharacter Define

Release a character which won't be used in this movie anymore.

1
4. PlaceObject Display

Place the specified object in the current display list.

1
5. RemoveObject Display

Remove the specified object at the specified depth.

1
6. DefineBitsJPEG Define

Define a JPEG bit stream.

1
7. DefineButton Define

Define an action button.

1
8. JPEGTables Define

Define the tables used to compress/decompress all the SWF 1.0 JPEG images (See also DefineBitsJPEG.)

1
9. SetBackgroundColor Display

Change the background color. Defaults to white if unspecified.

1
10. DefineFont Define

List shapes corresponding to glyphs.

1
11. DefineText Define

Defines a text of characters displayed using a font. This definition doesn't support any transparency.

1
12. DoAction Action

Actions to perform at the time the next show frame is reached and before the result is being displayed. It can duplicate sprites, start/stop movie clips, etc.

All the actions within a frame are executed sequentially in the order they are defined.

Important: many actions are not supported in Adobe Flash version 1. Please, see the reference of actions below in order to know which actions can be used with which version of Adobe Flash.

1
13. DefineFontInfo Define

Information about a previously defined font. Includes the font style, a map and the font name.

1
14. DefineSound Define

Declare a sound effect. This tag defines sound samples that can later be played back using either a StartSound or a DefineButtonSound. Note that the same DefineSound block can actually include multiple sound files and only part of the entire sound can be played back as required.

2
15. StartSound Display

Start playing the referenced sound on the next ShowFrame.

2
15. StopSound Display

Start playing the referenced sound on the next ShowFrame.

2
17. DefineButtonSound Define

Defines how to play a sound effect for when an event occurs on the referenced button.

2
18. SoundStreamHead Define

Declare a sound effect which will be interleaved with a movie data so as to be loaded over a network connection while being played.

2
19. SoundStreamBlock Define

A block of sound data (i.e. audio samples.) The size of this block of data is defined in the previous SoundStreamHead tag. It is used to download sound samples on a per frame basis instead of all at once.

2
20. DefineBitsLossless Define

A bitmap compressed using ZLIB (similar to the PNG format).

2
21. DefineBitsJPEG2 Define

Defines a complete JPEG image (includes the bit stream and the tables all in one thus enabling multiple tables to be used within the same SWF file).

Since Flash version 10, the data can also be set to a valid PNG or GIF89a. There is no need to specify the image format in the tag since the data describing the image includes the necessary information.

2
22. DefineShape2 Define

Brief Description: 

Define a simple geometric shape.

2
23. DefineButtonCxform Define

Setup a color transformation for a button.

2
24. Protect Define

Disable edition capabilities of the given SWF file. Though this doesn't need to be enforced by an SWF editor, it marks the file as being copyrighted in a way.

WARNING: this tag is only valid in Flash V2.x, V3.x, and V4.x, use the EnableDebugger instead in V5.x and EnableDebugger2 in V6.x and newer movies.

2
25. PathsArePostscript Define

The shape paths are defined as in postscript?

3
26. PlaceObject2 Define

Place, replace, remove an object in the current display list.

3
28. RemoveObject2 Display

Remove the object at the specified level. This tag should be used in movies version 3 and over since it compressed better than the standard RemoveObject tag. Note that a PlaceObject2 can also be used for this task.

3
29. SyncFrame Display

Tag used to synchronize the animation with the hardware.

3
31. FreeAll Define

Probably an action that would be used to clear everything out.

3
32. DefineShape3 Define

Brief Description: 

Define a simple geometric shape.

3
33. DefineText2 Define

Defines a text of characters displayed using a font. Transparency is supported with this tag.

3
34. DefineButton2 Define

Define an action button. Includes a color transformation. 

3
35. DefineBitsJPEG3 Define

Defines a complete JPEG image, i.e. a verbatim JPEG image file. The JPEG image is then followed by an alpha channel. Note that the alpha channel uses the Z-lib compression. Since Flash 10, the supported image formats are JPEG, PNG and GIF89a.

3
36. DefineBitsLossless2 Define

Defines an RGBA bitmap compressed using ZLIB (similar to the PNG format).

3
37. DefineEditText Define

An edit text enables the end users to enter text in a Flash window.

4
38. DefineVideo Define

Apparently, Macromedia did have a first attempt in supporting video on their platform. It looks, however, as if they reconsidered at that point in time.

4
39. DefineSprite Define

Declares an animated character. This is similar to a shape with a display list so the character can be changing on its own over time.

3
40. NameCharacter Define

Define the name of an object (for buttons, bitmaps, sprites and sounds.)

3
41. ProductInfo Define

This tag defines information about the product used to generate the animation. The product identifier should be unique among all the products. The info includes a product identifier, a product edition, a major and minor version, a build number and the date of compilation. All of this information is all about the generator, not the output movie.

3
42. DefineTextFormat Define

Another tag that Flash ended up not using.

1
43. FrameLabel Define

Names a frame or anchor. This frame can later be referenced using this name.

3
45. SoundStreamHead2 Define

Declare a sound effect which will be interleaved with a movie data so as to be loaded over a network connection while being played.

3
46. DefineMorphShape Define

This is similar to a sprite with a simple morphing between two shapes.

3
47. GenerateFrame Define

This may have been something similar to a New in an action script and thus was removed later.

3
48. DefineFont2 Define

Define a list of glyphs using shapes and other font metric information.

3
49. GeneratorCommand Define

Gives some information about the tool which generated this SWF file and its version.

3
50. DefineCommandObject Define

?

5
51. CharacterSet Define

It looks like this would have been some sort of DefineSprite extension... did not make it out either.

5
52. ExternalFont Define

It looks like accessing a system font was going to be another tag, but instead Macromedia made use of a flag in the existing DefineFont2 tag.

5
56. Export Define

Exports a list of definitions declared external so they can be used in other movies. You can in this way create one or more movies to hold a collection of objects to be reused by other movies without having to duplicate these in each movie. A single export is enough for an entire movie (and you should have just one).

5
57. Import Define

Imports a list of definitions that are to be loaded from another movie. You can retrieve objects that were exported in the specified movie. You can have as many import as you like, though you should really only have one per referenced movie.

5
58. EnableDebugger Format

The data of this tag is an MD5 password like the EnableDebugger2 tag. When it exists and you know the password, you will be given the right to debug the movie with Flash V5.x and higher.

WARNING: this tag is only valid in Flash V5.x, use the EnableDebugger2 instead in V6.x and newer movies and Protect in older movies (V2.x, V3.x, and V4.x).

5
59. DoInitAction Action

Actions to perform the first time the following Show Frame tag is reached. All the initialization actions are executed before any other actions. You have to specify a sprite to which the actions are applied to. Thus you don't need a set target action. When multiple initialization action blocks are within the same frame, they are executed one after another in the order they appear in that frame.

6
60. DefineVideoStream Define

Defines the necessary information for the player to display a video stream (i.e. size, codec, how to decode the data, etc.). Play the frames with VideoFrame tags.

6
61. VideoFrame Define

Show the specified video frame of a movie.

6
62. DefineFontInfo2 Define

Defines information about a font, like the DefineFontInfo tag plus a language reference. To force the use of a given language, this tag should be used in v6.x+ movies instead of the DefineFontInfo tag.

6
63. DebugID Define

This tag is used when debugging an SWF movie. It gives information about what debug file to load to match the SWF movie with the source. The identifier is a UUID.

6
64. EnableDebugger2 Format

The data of this tag is a 16 bits word followed by an MD5 password like the EnableDebugger tag. When it exists and you know the password, you will be given the right to debug the movie with Flash V6.x and over.

WARNING: this tag is only valid in Flash V6.x and over, use the EnableDebugger instead in V5.x and Protect in older movies (V2.x, V3.x, and V4.x).

6
65. ScriptLimits Define

Change limits used to ensure scripts do not use more resources than what you choose. In version 7, it supports a maximum recursive depth and a maximum amount of time scripts can be run for in seconds.

7
66. SetTabIndex Define

Define the order index so the player knows where to go next when the Tab key is pressed by the user.

7
69. FileAttributes Format

Since version 8, this tag is required and needs to be the very first tag in the movie. It is used as a way to better handle security within the Flash Player.

8
70. PlaceObject3 Display

Place an object in the display list. The object can include bitmap caching information, a blend mode and a set of filters.

8
71. Import2 Define

Imports a list of definitions from another movie. In version 8+, this tag replaces the original Import tag. You can retrieve objects which were exported in the specified movie. You can have as many import as you like, although you should really only have one per referenced movie.

8
72. DoABCDefine Action

New container tag for ActionScripts under SWF 9. Includes only actions. This tag is not defined in the official Flash documentation.

9
73. DefineFontAlignZones Define

Define advanced hints about a font glyphs to place them on a pixel boundary.

8
74. CSMTextSettings Define

Define whether CSM text should be used in a previous DefineText, DefineText2 or DefineEditText.

8
75. DefineFont3 Define

Define a list of glyphs using shapes and other font metric information.

8
76. SymbolClass Action

Instantiate objects from a set of classes.

9
77. Metadata Format

This tag includes XML code describing the movie. The format is RDF compliant to the XMP as defined on W3C.

8
78. DefineScalingGrid Define

Define scale factors for a window, a button, or other similar objects.

8
82. DoABC Action

New container tag for ActionScripts under SWF 9. Includes an identifier, a name and actions.

9
83. DefineShape4 Define

Declare a shape which supports new line caps, scaling and fill options.

8
84. DefineMorphShape2 Define

Declare a morphing shape with attributes supported by version 8+.

8
86. DefineSceneAndFrameData Define

Define raw data for scenes and frames.

9
87. DefineBinaryData Define

Defines a buffer of any size with any binary user data.

9
88. DefineFontName Define

Define the legal font name and copyright.

9
90. DefineBitsJPEG4 Define

Defines a complete JPEG (the image formats supported are JPEG, PNG and GIF89a) and includes a deblocking filter parameter. The JPEG image is then followed by an alpha channel. Note that the alpha channel uses the Z-lib compression.

10

CSMTextSettings

Tag Info
Tag Number: 
74
Tag Type: 
Define
Tag Flash Version: 
8
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define whether CSM text should be used in a previous DefineText, DefineText2 or DefineEditText.

Tag Structure: 
struct swf_csmtextsettings {
	swf_tag			f_tag;		/* 74 */
	unsigned short		f_text_id_ref;
	unsigned		f_use_flag_type : 2;
	unsigned		f_grid_fit : 3;
	unsigned		f_reserved : 3;
	long float		f_thickness;
	long float		f_sharpness;
	unsigned char		f_reserved;
};

The CSMTextSettings are used to change the rendering mode of glyphs in a DefineText, DefineText2 and DefineEditText.

The f_text_id_ref is a reference to a tag holding some texts which glyphs need to be tweaked with these settings.

The f_use_flag_type defines which of the system (0) or Flash (1) font renderer should be used.

Value Renderer Version
0 System 8
1 Internal Flash Type 8

The f_grid_fit defines whether the glyphs should be moved to fit on a grid (i.e. to look less blurry.)

Value Mode Version
0 No alignment 8
1 Pixel alignment (for left aligned text only — go figure!) 8
2 1/3rd pixel for LCD displays 8

The f_thickness and f_sharpness are used to compute the external and internal cutoff. According to Macromedia they compute these values as follow:

	External Cutoff = ( 0.5 × f_sharpness - f_thickness) × f_font_height
	Internal Cutoff = (-0.5 × f_sharpness - f_thickness) × f_font_height

CharacterSet

Tag Info
Tag Number: 
51
Tag Type: 
Define
Tag Flash Version: 
5
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

It looks like this would have been some sort of DefineSprite extension... did not make it out either.

Tag Structure: 

Unknown

Unknown

DebugID

Tag Info
Tag Number: 
63
Tag Type: 
Define
Tag Flash Version: 
6
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

This tag is used when debugging an SWF movie. It gives information about what debug file to load to match the SWF movie with the source. The identifier is a UUID.

Tag Structure: 
struct swf_debugid {
	swf_tag			f_tag;		/* 63 */
	unsigned char		f_uuid[<variable size>];
};

The DebugID tag is used to match a debug file (.swd) with a Flash animation (.swf). This is used by the Flash environment and is not required to create movies otherwise.

The f_uuid is a universally unique identifier. The size should be 128 bytes. It is otherwise defined by the size of the tag. All Unix and MS-Windows OSes offer a library to generate UUIDs. Although, you can very well just use a simple counter, it will work too.

DefineBinaryData

Tag Info
Tag Number: 
87
Tag Type: 
Define
Tag Flash Version: 
9
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Defines a buffer of any size with any binary user data.

Tag Structure: 
struct swf_definebinarydata {
	swf_tag			f_tag;		/* 87 */
	unsigned short		f_data_id;
	unsigned long		f_reserved;	/* must be zero */
	unsigned char		f_data[<variable size>];
};

The DefineBinaryData tag is used to save any arbitrary user defined binary data in an SWF movie. The Flash player itself ignores that data. The size of the data is not specifically limited.

The f_data_id is this object identifier. The identifier is the same type as any identifier (like a sprite identifier.) It is used in ActionScripts to reference the data.

The f_reversed area is 32 bits and it must be set to zero in version 9.

The size of the f_data buffer is defined as the size of the tag minus the f_data_id and f_reserved fields. This is where the raw binary data goes.

DefineBitsJPEG

Tag Info
Tag Number: 
6
Tag Type: 
Define
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define a JPEG bit stream.

Tag Structure: 
struct swf_definebitsjpeg {
	swf_long_tag		f_tag;		/* 6, 21, 35 or 90 */
	unsigned short		f_image_id;
	if(f_tag == DefineBitsJPEG3 + f_tag == DefineBitsJPEG4) {
		/* sizeof(f_encoding_tables) + sizeof(f_image_data) + 2 when JPEG4 */
		unsigned long		f_offset_to_alpha;
	}
	if(f_tag == DefineBitsJPEG4) {
		unsigned short fixed	f_deblocking_filter_parameter;
	}
	if(f_tag != DefineBitsJPEG) {
		/* when DefineBitsJPEG, use JPEGTables instead */
		unsigned char		f_encoding_tables[<variable size>];
	}
	unsigned char		f_image_data[<variable size>];
	if(f_tag == DefineBitsJPEG3 || f_tag == DefineBitsJPEG41) {
		unsigned char		f_alpha[<variable size>];
	}
};
  • 1. JPEG4 optionally accepts the f_alpha field. [To be verified]

These tags define an image saved using the JPEG compression scheme.

DefineBitsJPEG (V1.0) does not include the encoding tables which are defined in the unique JPEGTables tag instead. All the DefineBitsJPEG of an SWF file use the only JPEGTables tag. Yes... This means you need a tool that is capable of reusing the same tables over and over again to make sure that all your DefineBitsJPEGs work properly (or use it just once.)

The other tags incorporate their own version of the JPEG encoding tables.

The DefineBitsJPEG3 and DefineBitsJPEG4 support an alpha channel bit plane (8 bits.) This alpha channel is compressed using the ZLIB scheme as defined with the DefineBitsLossless image formats and appears at the end.

With Flash 10, DefineBitsJPEG4 was introduced to support a deblocking filter parameter. This parameter should be set to a value between 0.0 and 1.0 (0x0000 and 0x0100--so really a value from 0 to 256 inclusive.)

WARNING: These tags require you to save the swf_tag in long format (i.e. f_tag_and_size & 0x3F == 0x3F even if the size is smaller.)

f_encoding should include 0xFF 0xDB and 0xFF 0xC4 entries.

The f_image_data buffer should include the 0xFF 0xE0, 0xFF 0xC0 and 0xFF 0xDA.

Since Flash 10 the f_encoding and f_image_data fields defined in the DefineBitsJPEG2, DefineBitsJPEG3 and DefineBitsJPEG4 tags, are viewed as one single large buffer and thus it can be a verbatim JPEG, PNG or GIF89a file.

When the buffer represents a JPEG, it starts with 0xFF 0xD8 and ends with 0xFF 0xD9.

When the buffer represents a PNG, it starts with 0x89 0x50 'P' 0x4E 'N' 0x47 'G' 0x0D '\r' 0x0A '\n' 0x1A '^Z' 0x0A '\n'.

When the buffer represents a GIF89a, it starts with 0x47 'G' 0x49 'I' 0x46 'F' 0x38 '8' 0x39 '9' 0x61 'a'.

WARNING: Up to Flash 7, both buffers (f_encoding and f_image_data) need to start with a 0xFF 0xD8 (SOI) and end with 0xFF 0xD9 (EOI). Since Flash 8, this practice should not be used anymore.

The f_alpha buffer is compressed with ZLIB as defined in the DefineBitsLossless tag (this is similar to the PNG format). WARNING: this field only works with JPEG data. A PNG or GIF89a cannot make use of this field (but they can make use of their own alpha channel.)

Note:   The Flash 10 documentation says that the f_alpha field is optional. This means you can save a JPEG in a DefineBitsJPEG4 without the Alpha Channel but still make use of the deblocking filter parameter. Before Flash 10, use DefineBitsJPEG2 instead (safer).

The DefineBitsJPEG tag may fail if it includes any encoding tables. These tables shall be defined within the JPEGTables instead.

Note that the Adobe SWF player better enforces the correctness of these tags since version 8. Some older movies may not work properly with Flash Player 8+.

DefineBitsJPEG2

Tag Info
Tag Number: 
21
Tag Type: 
Define
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Defines a complete JPEG image (includes the bit stream and the tables all in one thus enabling multiple tables to be used within the same SWF file).

Since Flash version 10, the data can also be set to a valid PNG or GIF89a. There is no need to specify the image format in the tag since the data describing the image includes the necessary information.

Tag Structure: 

Tag Structure: 
struct swf_definebitsjpeg {
	swf_long_tag		f_tag;		/* 6, 21, 35 or 90 */
	unsigned short		f_image_id;
	if(f_tag == DefineBitsJPEG3 + f_tag == DefineBitsJPEG4) {
		/* sizeof(f_encoding_tables) + sizeof(f_image_data) + 2 when JPEG4 */
		unsigned long		f_offset_to_alpha;
	}
	if(f_tag == DefineBitsJPEG4) {
		unsigned short fixed	f_deblocking_filter_parameter;
	}
	if(f_tag != DefineBitsJPEG) {
		/* when DefineBitsJPEG, use JPEGTables instead */
		unsigned char		f_encoding_tables[<variable size>];
	}
	unsigned char		f_image_data[<variable size>];
	if(f_tag == DefineBitsJPEG3 || f_tag == DefineBitsJPEG41) {
		unsigned char		f_alpha[<variable size>];
	}
};
  • 1. JPEG4 optionally accepts the f_alpha field. [To be verified]

These tags define an image saved using the JPEG compression scheme.

DefineBitsJPEG (V1.0) does not include the encoding tables which are defined in the unique JPEGTables tag instead. All the DefineBitsJPEG of an SWF file use the only JPEGTables tag. Yes... This means you need a tool that is capable of reusing the same tables over and over again to make sure that all your DefineBitsJPEGs work properly (or use it just once.)

The other tags incorporate their own version of the JPEG encoding tables.

The DefineBitsJPEG3 and DefineBitsJPEG4 support an alpha channel bit plane (8 bits.) This alpha channel is compressed using the ZLIB scheme as defined with the DefineBitsLossless image formats and appears at the end.

With Flash 10, DefineBitsJPEG4 was introduced to support a deblocking filter parameter. This parameter should be set to a value between 0.0 and 1.0 (0x0000 and 0x0100--so really a value from 0 to 256 inclusive.)

WARNING: These tags require you to save the swf_tag in long format (i.e. f_tag_and_size & 0x3F == 0x3F even if the size is smaller.)

f_encoding should include 0xFF 0xDB and 0xFF 0xC4 entries.

The f_image_data buffer should include the 0xFF 0xE0, 0xFF 0xC0 and 0xFF 0xDA.

Since Flash 10 the f_encoding and f_image_data fields defined in the DefineBitsJPEG2, DefineBitsJPEG3 and DefineBitsJPEG4 tags, are viewed as one single large buffer and thus it can be a verbatim JPEG, PNG or GIF89a file.

When the buffer represents a JPEG, it starts with 0xFF 0xD8 and ends with 0xFF 0xD9.

When the buffer represents a PNG, it starts with 0x89 0x50 'P' 0x4E 'N' 0x47 'G' 0x0D '\r' 0x0A '\n' 0x1A '^Z' 0x0A '\n'.

When the buffer represents a GIF89a, it starts with 0x47 'G' 0x49 'I' 0x46 'F' 0x38 '8' 0x39 '9' 0x61 'a'.

WARNING: Up to Flash 7, both buffers (f_encoding and f_image_data) need to start with a 0xFF 0xD8 (SOI) and end with 0xFF 0xD9 (EOI). Since Flash 8, this practice should not be used anymore.

The f_alpha buffer is compressed with ZLIB as defined in the DefineBitsLossless tag (this is similar to the PNG format). WARNING: this field only works with JPEG data. A PNG or GIF89a cannot make use of this field (but they can make use of their own alpha channel.)

Note:   The Flash 10 documentation says that the f_alpha field is optional. This means you can save a JPEG in a DefineBitsJPEG4 without the Alpha Channel but still make use of the deblocking filter parameter. Before Flash 10, use DefineBitsJPEG2 instead (safer).

The DefineBitsJPEG tag may fail if it includes any encoding tables. These tables shall be defined within the JPEGTables instead.

Note that the Adobe SWF player better enforces the correctness of these tags since version 8. Some older movies may not work properly with Flash Player 8+.

DefineBitsJPEG3

Tag Info
Tag Number: 
35
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Defines a complete JPEG image, i.e. a verbatim JPEG image file. The JPEG image is then followed by an alpha channel. Note that the alpha channel uses the Z-lib compression. Since Flash 10, the supported image formats are JPEG, PNG and GIF89a.

Tag Structure: 

Tag Structure: 
struct swf_definebitsjpeg {
	swf_long_tag		f_tag;		/* 6, 21, 35 or 90 */
	unsigned short		f_image_id;
	if(f_tag == DefineBitsJPEG3 + f_tag == DefineBitsJPEG4) {
		/* sizeof(f_encoding_tables) + sizeof(f_image_data) + 2 when JPEG4 */
		unsigned long		f_offset_to_alpha;
	}
	if(f_tag == DefineBitsJPEG4) {
		unsigned short fixed	f_deblocking_filter_parameter;
	}
	if(f_tag != DefineBitsJPEG) {
		/* when DefineBitsJPEG, use JPEGTables instead */
		unsigned char		f_encoding_tables[<variable size>];
	}
	unsigned char		f_image_data[<variable size>];
	if(f_tag == DefineBitsJPEG3 || f_tag == DefineBitsJPEG41) {
		unsigned char		f_alpha[<variable size>];
	}
};
  • 1. JPEG4 optionally accepts the f_alpha field. [To be verified]

These tags define an image saved using the JPEG compression scheme.

DefineBitsJPEG (V1.0) does not include the encoding tables which are defined in the unique JPEGTables tag instead. All the DefineBitsJPEG of an SWF file use the only JPEGTables tag. Yes... This means you need a tool that is capable of reusing the same tables over and over again to make sure that all your DefineBitsJPEGs work properly (or use it just once.)

The other tags incorporate their own version of the JPEG encoding tables.

The DefineBitsJPEG3 and DefineBitsJPEG4 support an alpha channel bit plane (8 bits.) This alpha channel is compressed using the ZLIB scheme as defined with the DefineBitsLossless image formats and appears at the end.

With Flash 10, DefineBitsJPEG4 was introduced to support a deblocking filter parameter. This parameter should be set to a value between 0.0 and 1.0 (0x0000 and 0x0100--so really a value from 0 to 256 inclusive.)

WARNING: These tags require you to save the swf_tag in long format (i.e. f_tag_and_size & 0x3F == 0x3F even if the size is smaller.)

f_encoding should include 0xFF 0xDB and 0xFF 0xC4 entries.

The f_image_data buffer should include the 0xFF 0xE0, 0xFF 0xC0 and 0xFF 0xDA.

Since Flash 10 the f_encoding and f_image_data fields defined in the DefineBitsJPEG2, DefineBitsJPEG3 and DefineBitsJPEG4 tags, are viewed as one single large buffer and thus it can be a verbatim JPEG, PNG or GIF89a file.

When the buffer represents a JPEG, it starts with 0xFF 0xD8 and ends with 0xFF 0xD9.

When the buffer represents a PNG, it starts with 0x89 0x50 'P' 0x4E 'N' 0x47 'G' 0x0D '\r' 0x0A '\n' 0x1A '^Z' 0x0A '\n'.

When the buffer represents a GIF89a, it starts with 0x47 'G' 0x49 'I' 0x46 'F' 0x38 '8' 0x39 '9' 0x61 'a'.

WARNING: Up to Flash 7, both buffers (f_encoding and f_image_data) need to start with a 0xFF 0xD8 (SOI) and end with 0xFF 0xD9 (EOI). Since Flash 8, this practice should not be used anymore.

The f_alpha buffer is compressed with ZLIB as defined in the DefineBitsLossless tag (this is similar to the PNG format). WARNING: this field only works with JPEG data. A PNG or GIF89a cannot make use of this field (but they can make use of their own alpha channel.)

Note:   The Flash 10 documentation says that the f_alpha field is optional. This means you can save a JPEG in a DefineBitsJPEG4 without the Alpha Channel but still make use of the deblocking filter parameter. Before Flash 10, use DefineBitsJPEG2 instead (safer).

The DefineBitsJPEG tag may fail if it includes any encoding tables. These tables shall be defined within the JPEGTables instead.

Note that the Adobe SWF player better enforces the correctness of these tags since version 8. Some older movies may not work properly with Flash Player 8+.

DefineBitsJPEG4

Tag Info
Tag Number: 
90
Tag Type: 
Define
Tag Flash Version: 
10
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Defines a complete JPEG (the image formats supported are JPEG, PNG and GIF89a) and includes a deblocking filter parameter. The JPEG image is then followed by an alpha channel. Note that the alpha channel uses the Z-lib compression.

Tag Structure: 

Tag Structure: 
struct swf_definebitsjpeg {
	swf_long_tag		f_tag;		/* 6, 21, 35 or 90 */
	unsigned short		f_image_id;
	if(f_tag == DefineBitsJPEG3 + f_tag == DefineBitsJPEG4) {
		/* sizeof(f_encoding_tables) + sizeof(f_image_data) + 2 when JPEG4 */
		unsigned long		f_offset_to_alpha;
	}
	if(f_tag == DefineBitsJPEG4) {
		unsigned short fixed	f_deblocking_filter_parameter;
	}
	if(f_tag != DefineBitsJPEG) {
		/* when DefineBitsJPEG, use JPEGTables instead */
		unsigned char		f_encoding_tables[<variable size>];
	}
	unsigned char		f_image_data[<variable size>];
	if(f_tag == DefineBitsJPEG3 || f_tag == DefineBitsJPEG41) {
		unsigned char		f_alpha[<variable size>];
	}
};
  • 1. JPEG4 optionally accepts the f_alpha field. [To be verified]

These tags define an image saved using the JPEG compression scheme.

DefineBitsJPEG (V1.0) does not include the encoding tables which are defined in the unique JPEGTables tag instead. All the DefineBitsJPEG of an SWF file use the only JPEGTables tag. Yes... This means you need a tool that is capable of reusing the same tables over and over again to make sure that all your DefineBitsJPEGs work properly (or use it just once.)

The other tags incorporate their own version of the JPEG encoding tables.

The DefineBitsJPEG3 and DefineBitsJPEG4 support an alpha channel bit plane (8 bits.) This alpha channel is compressed using the ZLIB scheme as defined with the DefineBitsLossless image formats and appears at the end.

With Flash 10, DefineBitsJPEG4 was introduced to support a deblocking filter parameter. This parameter should be set to a value between 0.0 and 1.0 (0x0000 and 0x0100--so really a value from 0 to 256 inclusive.)

WARNING: These tags require you to save the swf_tag in long format (i.e. f_tag_and_size & 0x3F == 0x3F even if the size is smaller.)

f_encoding should include 0xFF 0xDB and 0xFF 0xC4 entries.

The f_image_data buffer should include the 0xFF 0xE0, 0xFF 0xC0 and 0xFF 0xDA.

Since Flash 10 the f_encoding and f_image_data fields defined in the DefineBitsJPEG2, DefineBitsJPEG3 and DefineBitsJPEG4 tags, are viewed as one single large buffer and thus it can be a verbatim JPEG, PNG or GIF89a file.

When the buffer represents a JPEG, it starts with 0xFF 0xD8 and ends with 0xFF 0xD9.

When the buffer represents a PNG, it starts with 0x89 0x50 'P' 0x4E 'N' 0x47 'G' 0x0D '\r' 0x0A '\n' 0x1A '^Z' 0x0A '\n'.

When the buffer represents a GIF89a, it starts with 0x47 'G' 0x49 'I' 0x46 'F' 0x38 '8' 0x39 '9' 0x61 'a'.

WARNING: Up to Flash 7, both buffers (f_encoding and f_image_data) need to start with a 0xFF 0xD8 (SOI) and end with 0xFF 0xD9 (EOI). Since Flash 8, this practice should not be used anymore.

The f_alpha buffer is compressed with ZLIB as defined in the DefineBitsLossless tag (this is similar to the PNG format). WARNING: this field only works with JPEG data. A PNG or GIF89a cannot make use of this field (but they can make use of their own alpha channel.)

Note:   The Flash 10 documentation says that the f_alpha field is optional. This means you can save a JPEG in a DefineBitsJPEG4 without the Alpha Channel but still make use of the deblocking filter parameter. Before Flash 10, use DefineBitsJPEG2 instead (safer).

The DefineBitsJPEG tag may fail if it includes any encoding tables. These tables shall be defined within the JPEGTables instead.

Note that the Adobe SWF player better enforces the correctness of these tags since version 8. Some older movies may not work properly with Flash Player 8+.

DefineBitsLossless

Tag Info
Tag Number: 
20
Tag Type: 
Define
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

A bitmap compressed using ZLIB (similar to the PNG format).

Tag Structure: 
struct swf_definebitslossless {
	swf_long_tag		f_tag;		/* 20 or 36 */
	unsigned short		f_image_id;
	unsigned char		f_format;	/* 3, 4 or 5 */
	unsigned short		f_width;
	unsigned short		f_height;
	if(f_format == 3) {
		unsigned char	f_colormap_count;
		if(f_tag == DefineBitsLossless) {
			swf_rgb		f_colormap[f_colormap_count];
		}
		else {
			swf_rgba	f_colormap[f_colormap_count];
		}
		unsigned char	f_indices[((f_width + 3) & -4) * f_height];
	}
	else {
		if(f_tag == DefineBitsLossless) {
			swf_xrgb	f_bitmap[f_width * f_height];
		}
		else {
			swf_argb	f_bitmap[f_width * f_height];
		}
	}
};

These tags declares a loss-less image bitmap. It has a small header followed by an optional colormap and the bitmap data. When we have a colormap, the bitmap data is an array of indices in the colormap aligned to 4 bytes on a per row basis.

There are three supported formats:

Format
No.
(bits)
Color Format Comments
Without
Alpha
With
Alpha
3
(8 bits(1))
RGB RGBA Uses a colormap with up to 256 entries of 24 or 32 bits colors.
4
(16 bits(1))
RGB555 RGB555 There is no alpha available in this format. The data is saved in big endian (it is NOT a U16 like some documentations say it is). The colors looks like this (most significant bit first): 0RRRRRGGGGGBBBBB. You should certainly always use the DefineBitsLossless tag for this format.
5
(32 bits)
XRGB ARGB Uses a strange order for the components. Most probably because the alpha was added later and thus inserted in place of the X to keep some backward compatibility with older versions.

(1) the data must be 32 bits aligned (4 bytes) on a per row basis. In 8 bits, you may have to add up to three bytes at the end of each row ( 4 - width & 3 when width & 3 is not zero.). In 16 bits, you need to add two bytes at the end of each row when the width of the image is odd.

The f_colormap, f_indices and f_bitmap are all compressed with the ZLIB scheme.

WATCH OUT: the f_colormap and f_indices are compressed as one large block.

WARNING: These tags require you to save the swf_tag in long format (i.e. f_tag_and_size & 0x3F == 0x3F even if the size is smaller than 63.)

WARNING: An image cannot always be scaled more than 64×. Trying to enlarge it more may result in a rectangle of one color. The 64× is cumulative. So a sprite of an image × 3 inside another sprite × 10 inside another sprite × 4 results in scaling of 120 and this is likely to break the image. This seems to be true mainly when there is a rotation or skew.

DefineBitsLossless2

Tag Info
Tag Number: 
36
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Defines an RGBA bitmap compressed using ZLIB (similar to the PNG format).

Tag Structure: 

Tag Structure: 
struct swf_definebitslossless {
	swf_long_tag		f_tag;		/* 20 or 36 */
	unsigned short		f_image_id;
	unsigned char		f_format;	/* 3, 4 or 5 */
	unsigned short		f_width;
	unsigned short		f_height;
	if(f_format == 3) {
		unsigned char	f_colormap_count;
		if(f_tag == DefineBitsLossless) {
			swf_rgb		f_colormap[f_colormap_count];
		}
		else {
			swf_rgba	f_colormap[f_colormap_count];
		}
		unsigned char	f_indices[((f_width + 3) & -4) * f_height];
	}
	else {
		if(f_tag == DefineBitsLossless) {
			swf_xrgb	f_bitmap[f_width * f_height];
		}
		else {
			swf_argb	f_bitmap[f_width * f_height];
		}
	}
};

These tags declares a loss-less image bitmap. It has a small header followed by an optional colormap and the bitmap data. When we have a colormap, the bitmap data is an array of indices in the colormap aligned to 4 bytes on a per row basis.

There are three supported formats:

Format
No.
(bits)
Color Format Comments
Without
Alpha
With
Alpha
3
(8 bits(1))
RGB RGBA Uses a colormap with up to 256 entries of 24 or 32 bits colors.
4
(16 bits(1))
RGB555 RGB555 There is no alpha available in this format. The data is saved in big endian (it is NOT a U16 like some documentations say it is). The colors looks like this (most significant bit first): 0RRRRRGGGGGBBBBB. You should certainly always use the DefineBitsLossless tag for this format.
5
(32 bits)
XRGB ARGB Uses a strange order for the components. Most probably because the alpha was added later and thus inserted in place of the X to keep some backward compatibility with older versions.

(1) the data must be 32 bits aligned (4 bytes) on a per row basis. In 8 bits, you may have to add up to three bytes at the end of each row ( 4 - width & 3 when width & 3 is not zero.). In 16 bits, you need to add two bytes at the end of each row when the width of the image is odd.

The f_colormap, f_indices and f_bitmap are all compressed with the ZLIB scheme.

WATCH OUT: the f_colormap and f_indices are compressed as one large block.

WARNING: These tags require you to save the swf_tag in long format (i.e. f_tag_and_size & 0x3F == 0x3F even if the size is smaller than 63.)

WARNING: An image cannot always be scaled more than 64×. Trying to enlarge it more may result in a rectangle of one color. The 64× is cumulative. So a sprite of an image × 3 inside another sprite × 10 inside another sprite × 4 results in scaling of 120 and this is likely to break the image. This seems to be true mainly when there is a rotation or skew.

DefineButton

Tag Info
Tag Number: 
7
Tag Type: 
Define
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define an action button.

Tag Structure: 
struct swf_definebutton {
	swf_tag			f_tag;		/* 7 */
	unsigned short		f_button_id;
	swf_button		f_buttons;
	swf_action		f_actions;
};

Mouse interactivity in the SWF format comes from the buttons. All the buttons have an identifier and can be placed in the display list like any other shape.

A buttons has different states. Some states can be entered only when the button was in a specific state before (like a button being pushed).

Buttons can be represented graphically in any manner you want. Each state can use a different edit text, shape, sprite or text to render the button.

The f_buttons and f_actions are null terminated arrays (the end marker in either case is a byte set to zero).

There will always be at least one f_buttons since the object require at least one shape to be rendered (though the shape can very well be transparent and empty).

There is no need for any action. The actions are executed whenever the button is pushed. Note that it is possible to execute actions also when the mouse moves over a button (in, out, over) with the use of a sprite in version 5+. However, in this case it is certainly preferable to use a DefineButton2 instead.

DefineButton2

Tag Info
Tag Number: 
34
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define an action button. Includes a color transformation. 

Tag Structure: 
struct swf_definebutton2 {
	swf_tag		f_tag;		/* 34 */
	unsigned short		f_button_id;
	unsigned		f_reserved : 7;
	unsigned		f_menu : 1;
	unsigned short		f_buttons_size;
	swf_button		f_buttons;
	swf_condition		f_conditions;
};

The DefineButton2 is very similar to the DefineButton tag. The list of actions was however changed in a list of actions to execute on a condition. Whenever an event occur, the plugin checks for that condition within all the buttons which can possibly catch that event at the time. For all the matches it finds, the corresponding actions are executed.

The f_buttons_size is equal to the size of the f_buttons buffer plus 2 (the size of the f_buttons_size field itself). Note however that if you don't have any conditions, the f_buttons_size field will be zero (0). This is similar to the list of conditions which also ends with a condition having a size of zero (0). You can still deduce the size of the f_buttons when the f_button_size is zero by using the total tag size minus the offset where the f_buttons declarations start.

DefineButtonCxform

Tag Info
Tag Number: 
23
Tag Type: 
Define
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Setup a color transformation for a button.

Tag Structure: 
struct swf_definebuttoncxform {
	swf_tag			f_tag;		/* 23 */
	unsigned short		f_button_id_ref;
	swf_color_transform	f_color_transform;
};

The DefineButton does not include any means to transform the colors of the shapes it uses. This tag was thus added just so one can transform a button colors. It is wise to use the new DefineButton2 instead so the transformation can be applied on a per state basis.

The f_button_id_ref is a reference to the button to be transformed with the specified color matrix. The button should be defined first.

DefineButtonSound

Tag Info
Tag Number: 
17
Tag Type: 
Define
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Defines how to play a sound effect for when an event occurs on the referenced button.

Tag Structure: 
enum {
	DEFINE_BUTTON_SOUND_CONDITION_POINTER_LEAVE = 0,
	DEFINE_BUTTON_SOUND_CONDITION_POINTER_ENTER = 1,
	DEFINE_BUTTON_SOUND_CONDITION_POINTER_PUSH = 2,
	DEFINE_BUTTON_SOUND_CONDITION_POINTER_RELEASE_INSIDE = 3,
	DEFINE_BUTTON_SOUND_CONDITION_MAX = 4
};

struct swf_definebuttonsound {
	swf_tag			f_tag;		/* 17 */
	unsigned short		f_button_id_ref;
	swf_sound_info		f_button_sound_condition[DEFINE_BUTTON_SOUND_CONDITION_MAX];
};

The DefineButtonSound can be used to emit a sound when an event occur on the specified button. It is likely better to use sprites that you display using actions than to use this tag. You will have access to more events and conditions, plus this tag always includes four sound effect references.

The f_button_id_ref is a reference to the button given sound effects.

There are four f_button_sound_condition. Each have a reference to a sound and some information on how to play it. The four conditions are given in the enumeration preceeding the DefineButtonSound structure.

DefineCommandObject

Tag Info
Tag Number: 
50
Tag Type: 
Define
Tag Flash Version: 
5
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

?

Tag Structure: 

Unknown

Unknown

DefineEditText

Tag Info
Tag Number: 
37
Tag Type: 
Define
Tag Flash Version: 
4
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

An edit text enables the end users to enter text in a Flash window.

Tag Structure: 
struct swf_defineedittext {
	swf_tag			f_tag;		/* 37 */
	unsigned short		f_edit_id;
	swf_rect		f_rect;
	unsigned		f_edit_has_text : 1;
	unsigned		f_edit_word_wrap : 1;
	unsigned		f_edit_multiline : 1;
	unsigned		f_edit_password : 1;
	unsigned		f_edit_readonly : 1;
	unsigned		f_edit_has_color : 1;
	unsigned		f_edit_has_max_length : 1;
	unsigned		f_edit_has_font : 1;
	if(version >= 6) {
		unsigned		f_edit_reserved : 1;
		unsigned		f_edit_auto_size : 1;
	}
	else {
		unsigned		f_edit_reserved : 2;
	}
	unsigned		f_edit_has_layout : 1;
	unsigned		f_edit_no_select : 1;
	unsigned		f_edit_border : 1;
	unsigned		f_edit_reserved : 1;
	unsigned		f_edit_html : 1;
	unsigned		f_edit_use_outlines : 1;
	if(f_edit_has_font) {
		unsigned short		f_edit_font_id_ref;
		unsigned short		f_edit_font_height;
	}
	if(f_edit_has_color) {
		swf_rgba		f_edit_color;
	}
	if(f_edit_has_max_length) {
		unsigned short		f_edit_max_length;
	}
	if(f_edit_has_layout) {
		unsigned char		f_edit_align;
		unsigned short		f_edit_left_margin;
		unsigned short		f_edit_right_margin;
		signed short		f_edit_indent;
		signed short		f_edit_leading;
	}
	string			f_edit_variable_name;
	if(f_edit_has_text) {
		string			f_edit_initial_text;
	}
};

Additional interactivity has been added in V4.0 of the SWF format. This is given by the use of edit boxes offering the end users a way to enter text as if the SWF movie was in fact an interactive form.

The text is defined in a variable (accessible in action scripts). It can be dynamically assigned and retrieved. It is legal to have an empty string as the variable name (not dynamically accessible).

Since version 8, the text drawn by a DefineEditText tag can be tweaked by adding a CSMTextSettings tag.

The f_edit_word_wrap flag will be set to true (1) in order to have words going beyond the right side of the box appear on the next line instead. This only works if you have the f_edit_multiline flag set to true.

The f_edit_multiline flag can be used to create an edit text field that accepts new lines and can wrap lines on word boundaries (see f_edit_word_wrap).

The f_edit_readonly flag ensures that the end user cannot modify the text in the edit box (i.e. dynamic box used for display only.)

The f_edit_has_color & f_edit_color are used to indicate the color of the text. Note that it is possible to ask for a border and a background to be drawn (see the f_edit_border flag below) but these items colors cannot be defined.

The f_edit_has_max_length & f_edit_max_length can be used to ensure the user can't type more than a certain number of letters and digits.

The f_edit_password flag is used to visually transform the typed characters to asterisks. The edit text field variable has the characters as typed, obviously. You do not have control over the character used to hide the text.

The f_edit_border is used to not only draw a border, but also have a white background. Make sure you don't select a light color for your font or you won't see any text in this case. The color of the border is likely to be black. If you want to have better control of these colors you will have to draw your own background and borders with a DefineShape tag.

The f_edit_auto_size flag requests the player to automatically resize the object to the text. Thus, you do not need to know the size of the text at the time you create an edit text, plus different fonts from different platforms will always fit the edit text (but maybe not the screen...).

The f_edit_use_outlines flag will be used to tell whether the specified SWF internal font should be used. When not set, a default font is chosen by the player. Internal fonts need to include a mapping with all the characters expected to be used so it can be rendered properly. The mapping must correspond to the UCS-2 encoding to be valid. When using 8 bits, the ISO-8859-1 font encoding must be used.

The f_edit_align can be set to the following values:

Alignment Value
Left 0x00
Right 0x01
Center 0x02
Justify(1) 0x03

(1) justification doesn't seem to work yet.

The f_edit_indent is the first line indentation in a multiline box of text. This is added to the left margin. The f_edit_leading is the number of extra pixels to skip to reach the following line. It should be put to zero to have the default font leading value.

The f_edit_left/right_margin indicate how many TWIPS to not use on the sides. If you don't use a border, these are rather useless.

The f_edit_html flag, when set, means the contents of this edit text box is basic HTML. The following table shows you the tags that the Macromedia plugin understands.

Tag Accepted Attributes Comments
Open Close
<A> </A>
HREF=url
[ TARGET=name ]
Defines an hyperlink
<B> </B> none Write in bold
<BR> n.a. none Inserts a line break
<FONT> </FONT>
[ FACE=name ]
[ SIZE=[+|-][0-9]+ ]
[ COLOR=#RRGGBB ]
Change the font face. The face name must match a DefineFont2 name. The size is in TWIPS. The color only supports #RRGGBB triplets.
<I> </I> none Write in italic
<LI> </LI> none Defines a list item
<P> </P>
[ ALIGN=left|right|center ]
Defines a paragraph
<TAB> n.a. none Inserts a tab character (see TEXTFORMATalso)
<TEXTFORMAT> </TEXTFORMAT>
[ BLOCKINDENT=[0-9]+ ]
[ INDENT=[0-9]+ ]
[ LEADING=[0-9]+ ]
[ LEFTMARGIN=[0-9]+ ]
[ RIGHTMARGIN=[0-9]+ ]
[ TABSTOPS=[0-9]+{,[0-9]+} ]
Change the different parameters as indicated. The sizes are all in TWIPs. There can be multiple positions for the tab stops. These are separated by commas.
<U> </U> none Write with an underline

For more information about HTML, please, refer to a full HTML documentation. You can find the complete specification at https://www.w3.org/. It was written by the MIT, INRIA and Keio and that's very well written! Remember that the DefineEditText HTML is limited to what is listed here.

WARNING:

There are several problems with the use of system fonts.

  1. When the named system font does not exist on a system, nothing appears... Note that Helvetica is not generally available on most Linux systems.
  2. A text with a system font cannot be rotated.
  3. System fonts do not support an alpha channel.
  4. The size used to render a system font is much more restricted than a Flash font.
  5. The size used for a system font is not in TWIPS (if I'm correct, it is in points instead.)

DefineFont

Tag Info
Tag Number: 
10
Tag Type: 
Define
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

List shapes corresponding to glyphs.

Tag Structure: 
struct swf_definefont {
	swf_tag			f_tag;		/* 10 */
	unsigned short		f_font_id;
	/* there is always at least one glyph */
	f_font_glyphs_count = f_font_offsets[0] / 2;
	unsigned short		f_font_offsets[f_font_glyphs_count];
	swf_shape		f_font_shapes[f_font_glyphs_count];
};

It is common to use the DefineFont tag in order to create an array of shapes later re-used to draw strings of text on the screen. Note that the definition of the shape within a font is limited since it can't include any specific fill and/or line style. Also, each shape is assumed to be defined within a 1024x1024 square. This square is called the EM Square. Fig 1. below shows you the EM Square and how it is used. The characters baseline can be placed anywhere within the EM Square (it certainly can be outside too if you wish?!?). The baseline is the position where the Y coordinate of the font is set to 0. The characters have to be drawn over that line to be properly defined. Only letters such as g, j, p and q will have a part drawn below. This means all the main characters will use negative Y coordinates. The Y coordinates increase from top to bottom (opposite the TrueType fonts and possibly others too.) The width gives the number of TWIPs between this character and the next to be drawn on the right. The drawing should not go outside the EM Square (what happens in this case is not specified, it is likely that what is drawn outside will be lost but it can have some side effects too.)

Though it is possible to define a font which draws from right to left (such as an Arabic or Farsi font), it may cause problems (I didn't try yet...)



Fig 1. Font EM Square

With SSWF, you can see the EM Square of a character adding this code in your glyph definition (where <descent> is the descent value as saved in the layout of the font):

	glyph "test" {
		...
		move: 0, -<descent>;
		points { 0, 1024; 1024, 1024; 1024, 0; 0, 0; };
		...
	};

The font structure defines the font identifier (which is common with a corresponding DefineFontInfo) an array of offsets and an array of glyphs. Note that if a DefineFontInfo tag is to be saved, you need to have the glyphs ordered in ascending order ('a' before 'b', etc.) This is important for the definition of the map present in the DefineFontInfo.

You must use a DefineFont2 if a DefineEditText references a font. It will either fail or crash the Flash plugin if you use this font definition instead.

Note that an embedded font can be rotated. A system font (also called a device font) cannot be rotated. Also, the scaling and translation of a system font does not always respect the exact position. It is likely that the font will be moved to the next pixel left or right to avoid blurriness. That means it will look quite jaggedly if you try to have a slow and smooth move.

The f_offsets array is a list of byte offsets given from the beginning of the f_offsets array itself to the beginning of the corresponding shape. (If it were possible to write such structure in C, then ...) In C one would write the following to find the shape in the font tag:

	struct swf_definefont	*df;
	df = ...
	character67 = (struct swf_shape *) ((char *) df->f_offsets + df->f_offsets[67]);

Since version 9, you can complement the definition of a font with the DefineFontName tag. This tag includes the legal name of the font and a copyright string.

DefineFont2

Tag Info
Tag Number: 
48
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define a list of glyphs using shapes and other font metric information.

Tag Structure: 
struct swf_definefont2 {
	swf_tag			f_tag;		/* 48 or 75 */
	unsigned short		f_font2_id;
	unsigned		f_font2_has_layout : 1;
	if(version >= 6) {
		unsigned	f_font2_reserved : 1;
		if(version >= 7) {
			unsigned	f_font2_small_text : 1;
		}
		unsigned	f_font2_reserved : 1;
	}
	else {
		unsigned	f_font2_shiftjis : 1;
		unsigned	f_font2_unicode : 1;
		unsigned	f_font2_ansii : 1;
	}
	unsigned		f_font2_wide_offsets : 1;
	unsigned		f_font2_wide : 1;	/* always 1 in v6.x+ */
	unsigned		f_font2_italic : 1;
	unsigned		f_font2_bold : 1;
	if(version >= 6) {
		unsigned char	f_font2_language;
	}
	else {
		unsigned char	f_font2_reserved;
	}
	unsigned char		f_font2_name_length;
	unsigned char		f_font2_name[f_font2_name_length];
	unsigned short		f_font2_glyphs_count;
	if(f_font2_wide_offsets) {
		unsigned long		f_font2_offsets[f_font2_glyphs_count];
		unsigned long		f_font2_map_offset;
	}
	else {
		unsigned short		f_font2_offsets[f_font2_glyphs_count];
		unsigned short		f_font2_map_offset;
	}
	swf_shape		f_font2_shapes[f_font2_glyphs_count];
	if(f_font_info_wide) {
		unsigned short		f_font2_map[f_font2_glyphs_count];
	}
	else {
		unsigned char		f_font2_map[f_font2_glyphs_count];
	}
	if(f_font2_has_layout) {
		signed short		f_font2_ascent;
		signed short		f_font2_descent;
		signed short		f_font2_leading_height;
		signed short		f_font2_advance[f_font2_glyphs_count];
		swf_rect		f_font2_bounds[f_font2_glyphs_count];
		signed short		f_font2_kerning_count;
		swf_kerning		f_font2_kerning[f_font2_kerning_count];
	}
};
/* DefineFont3 is the same as DefineFont2 */
typedef struct swf_definefont2 swf_definefont3;

It is common to use the DefineFont2 tag in order to create an array of shapes later re-used to draw strings of text on the screen. This tag must be used whenever a DefineEditText references a font; and in that case it is suggested you include a full description of the font with layouts.

The array of glyphs must be ordered in ascending order (the smaller glyph number saved first; thus 'a' must be saved before 'b', etc.).

All the characters should be defined in a 1024x1024 square (in pixels) to be drawn with the best possible quality. This square is called the EM square.

The DefineFont3 tag has the exact same definition as the DefineFont2 tag. The difference lies in the shapes being referenced. These have a precision 20 times higher. This gives you a font with that much higher precision (each pixel can be divided in a 400 sub-pixels.) The other difference is that a DefineFont3 can be referenced by a DefineFontAlignZones tag. That one can be used to properly align characters on a pixel boundary.

Note that an embedded font can be rotated. A system font (also called a device font) cannot be rotated. Also, the scaling and translation of a system font does not always respect the exact position. It is likely that the font will be moved to the next pixel left or right to avoid bluriness. That means it will look quite jaggy if you try to have a quite smooth move.

Since V6.x the f_font2_wide must always be set to 1.

The f_font2_shiftjis, f_font2_unicode and f_font2_ansii flags are for older movies (SWF 5 or older). Note that these are still defined as is in the Macromedia documentation (except for the Unicode flag which is implied and was replaced by another flag in version 7.) I strongly suggest that you follow my structure and totally ignore these flags (set them to 0) in newer movies.

The f_offsets array is a list of byte offsets given from the beginning of the f_offsets array itself (and not the beginning of the tag) to the beginning of the corresponding shape.

f_font2_map_offset is the offset to the f_font2_map table. This offset is relative to the position of the f_offsets array. It very much looks like it is part of that table. This offset should always be present, though if the font is not used in a DefineEditText tag, older version of the Flash player would still work just fine.

The f_font2_kerning_count and f_font2_kerning are used since version 8. Before that, just put the kerning count to zero and do not save any kerning.

(If it were possible to write such a structure as is in C, then ...) In C one would write the following to find the shape in the font tag:

	struct swf_definefont2	*df;

	df = ...
	character67 = (struct swf_shape *) ((char *) df->f_offsets + df->f_offsets[67]);

DefineFont3

Tag Info
Tag Number: 
75
Tag Type: 
Define
Tag Flash Version: 
8
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define a list of glyphs using shapes and other font metric information.

Tag Structure: 

Tag Structure: 
struct swf_definefont2 {
	swf_tag			f_tag;		/* 48 or 75 */
	unsigned short		f_font2_id;
	unsigned		f_font2_has_layout : 1;
	if(version >= 6) {
		unsigned	f_font2_reserved : 1;
		if(version >= 7) {
			unsigned	f_font2_small_text : 1;
		}
		unsigned	f_font2_reserved : 1;
	}
	else {
		unsigned	f_font2_shiftjis : 1;
		unsigned	f_font2_unicode : 1;
		unsigned	f_font2_ansii : 1;
	}
	unsigned		f_font2_wide_offsets : 1;
	unsigned		f_font2_wide : 1;	/* always 1 in v6.x+ */
	unsigned		f_font2_italic : 1;
	unsigned		f_font2_bold : 1;
	if(version >= 6) {
		unsigned char	f_font2_language;
	}
	else {
		unsigned char	f_font2_reserved;
	}
	unsigned char		f_font2_name_length;
	unsigned char		f_font2_name[f_font2_name_length];
	unsigned short		f_font2_glyphs_count;
	if(f_font2_wide_offsets) {
		unsigned long		f_font2_offsets[f_font2_glyphs_count];
		unsigned long		f_font2_map_offset;
	}
	else {
		unsigned short		f_font2_offsets[f_font2_glyphs_count];
		unsigned short		f_font2_map_offset;
	}
	swf_shape		f_font2_shapes[f_font2_glyphs_count];
	if(f_font_info_wide) {
		unsigned short		f_font2_map[f_font2_glyphs_count];
	}
	else {
		unsigned char		f_font2_map[f_font2_glyphs_count];
	}
	if(f_font2_has_layout) {
		signed short		f_font2_ascent;
		signed short		f_font2_descent;
		signed short		f_font2_leading_height;
		signed short		f_font2_advance[f_font2_glyphs_count];
		swf_rect		f_font2_bounds[f_font2_glyphs_count];
		signed short		f_font2_kerning_count;
		swf_kerning		f_font2_kerning[f_font2_kerning_count];
	}
};
/* DefineFont3 is the same as DefineFont2 */
typedef struct swf_definefont2 swf_definefont3;

It is common to use the DefineFont2 tag in order to create an array of shapes later re-used to draw strings of text on the screen. This tag must be used whenever a DefineEditText references a font; and in that case it is suggested you include a full description of the font with layouts.

The array of glyphs must be ordered in ascending order (the smaller glyph number saved first; thus 'a' must be saved before 'b', etc.).

All the characters should be defined in a 1024x1024 square (in pixels) to be drawn with the best possible quality. This square is called the EM square.

The DefineFont3 tag has the exact same definition as the DefineFont2 tag. The difference lies in the shapes being referenced. These have a precision 20 times higher. This gives you a font with that much higher precision (each pixel can be divided in a 400 sub-pixels.) The other difference is that a DefineFont3 can be referenced by a DefineFontAlignZones tag. That one can be used to properly align characters on a pixel boundary.

Note that an embedded font can be rotated. A system font (also called a device font) cannot be rotated. Also, the scaling and translation of a system font does not always respect the exact position. It is likely that the font will be moved to the next pixel left or right to avoid bluriness. That means it will look quite jaggy if you try to have a quite smooth move.

Since V6.x the f_font2_wide must always be set to 1.

The f_font2_shiftjis, f_font2_unicode and f_font2_ansii flags are for older movies (SWF 5 or older). Note that these are still defined as is in the Macromedia documentation (except for the Unicode flag which is implied and was replaced by another flag in version 7.) I strongly suggest that you follow my structure and totally ignore these flags (set them to 0) in newer movies.

The f_offsets array is a list of byte offsets given from the beginning of the f_offsets array itself (and not the beginning of the tag) to the beginning of the corresponding shape.

f_font2_map_offset is the offset to the f_font2_map table. This offset is relative to the position of the f_offsets array. It very much looks like it is part of that table. This offset should always be present, though if the font is not used in a DefineEditText tag, older version of the Flash player would still work just fine.

The f_font2_kerning_count and f_font2_kerning are used since version 8. Before that, just put the kerning count to zero and do not save any kerning.

(If it were possible to write such a structure as is in C, then ...) In C one would write the following to find the shape in the font tag:

	struct swf_definefont2	*df;

	df = ...
	character67 = (struct swf_shape *) ((char *) df->f_offsets + df->f_offsets[67]);

DefineFontAlignZones

Tag Info
Tag Number: 
73
Tag Type: 
Define
Tag Flash Version: 
8
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define advanced hints about a font glyphs to place them on a pixel boundary.

Tag Structure: 
struct swf_definefontalignzones {
	swf_tag			f_tag;		/* 73 */
	unsigned short		f_font2_id_ref;
	unsigned		f_csm_table_hint : 2;
	unsigned		f_reserved : 6;
	swf_zone_array		f_zones[corresponding define font3.f_font2_glyphs_count];
};

Since SWF8, this tag was added to allow a clear definition of where a glyph starts. This is a hint to ensure that glyphs are properly drawn on pixel boundaries. Note that it is only partially useful for italic fonts since only vertical hints really make a difference.

The f_font2_id_ref needs to reference the font identifier of a DefineFont3. Each DefineFontAlignZones shall have a different f_font2_id_ref.

The f_csm_table_hint field can be set to one of the values as defined in the following table. It refers to the thickness of the stroke. This is only a hint meaning that the Flash Player may not use this information if it thinks it knows better about the font you are trying to render.

Value Name Version
0 Thin 8
1 Medium 8
2 Thick 8

DefineFontInfo

Tag Info
Tag Number: 
13
Tag Type: 
Define
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Information about a previously defined font. Includes the font style, a map and the font name.

Tag Structure: 
struct swf_definefontinfo {
	swf_tag			f_tag;		/* 13 or 62 */
	unsigned short		f_font_info_id_ref;
	unsigned char		f_font_info_name_length;
	unsigned char		f_font_info_name[f_name_length];
	if(version >= 7 && f_tag.f_tag == DefineFontInfo2) {
		unsigned		f_font_info_reserved : 2;
		unsigned		f_font_info_small_text : 1;
		unsigned		f_font_info_reserved : 2;
	}
	else if(version >= 6 && f_tag.f_tag == DefineFontInfo2) {
		unsigned		f_font_info_reserved : 5;
	}
	else {
		unsigned		f_font_info_reserved : 2;
		unsigned		f_font_info_unicode : 1;
		unsigned		f_font_info_shiftjis : 1;
		unsigned		f_font_info_ansii : 1;
	}
	unsigned		f_font_info_italic : 1;
	unsigned		f_font_info_bold : 1;
	unsigned		f_font_info_wide : 1;	/* always 1 in v6.x+ */
	if(version >= 6 && f_tag.f_tag == DefineFontInfo2) {
		unsigned char		f_font_info_language;
	}
	if(f_font_info_wide) {
		unsigned short		f_font_info_map[f_font_glyphs_count];
	}
	else {
		unsigned char		f_font_info_map[f_font_glyphs_count];
	}
};

A DefineFontInfo tag will be used to complete the definition of a DefineFont tag. It uses the exact same identifier (f_font_info_id_ref = f_font_id). You must have the corresponding font definition appearing before the DefineFontInfo since it will use the number of glyphs defined in the DefineFont to know the size of the map definition in the DefineFontInfo tag.

When it looks like it perfectly matches an existing system font, the plugin may use that system font (as long as no rotation is used, it will work fine.) It is also possible to force the use of the system font by declaring an empty DefineFont tag (i.e. no glyph declaration at all.)

The use of system fonts usually ensures a much better quality of smaller prints. However, since version 8, there are many features in the Flash player taking care of really small fonts.

Note, however, that a system font (also called a device font) cannot be rotated. Also, the scaling and translation of a system font does not always respect the exact position. It is likely that the font will be moved to the next pixel left or right to avoid blurriness. That means it will look quite jaggedly when slowly moving such text.

The f_font_info_wide flag must be set to 1 in version 6 and over.

Note that the flag f_font_info_small_text of version 7+ is the same bit as the flag f_font_info_unicode in SWF version 5 or less.

Since version 6, the font name has to be encoded in UTF-8 instead of whatever encoding you want. It is also suggested that you use the DefineFontInfo2 tag instead.

DefineFontInfo2

Tag Info
Tag Number: 
62
Tag Type: 
Define
Tag Flash Version: 
6
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Defines information about a font, like the DefineFontInfo tag plus a language reference. To force the use of a given language, this tag should be used in v6.x+ movies instead of the DefineFontInfo tag.

Tag Structure: 

Tag Structure: 
struct swf_definefontinfo {
	swf_tag			f_tag;		/* 13 or 62 */
	unsigned short		f_font_info_id_ref;
	unsigned char		f_font_info_name_length;
	unsigned char		f_font_info_name[f_name_length];
	if(version >= 7 && f_tag.f_tag == DefineFontInfo2) {
		unsigned		f_font_info_reserved : 2;
		unsigned		f_font_info_small_text : 1;
		unsigned		f_font_info_reserved : 2;
	}
	else if(version >= 6 && f_tag.f_tag == DefineFontInfo2) {
		unsigned		f_font_info_reserved : 5;
	}
	else {
		unsigned		f_font_info_reserved : 2;
		unsigned		f_font_info_unicode : 1;
		unsigned		f_font_info_shiftjis : 1;
		unsigned		f_font_info_ansii : 1;
	}
	unsigned		f_font_info_italic : 1;
	unsigned		f_font_info_bold : 1;
	unsigned		f_font_info_wide : 1;	/* always 1 in v6.x+ */
	if(version >= 6 && f_tag.f_tag == DefineFontInfo2) {
		unsigned char		f_font_info_language;
	}
	if(f_font_info_wide) {
		unsigned short		f_font_info_map[f_font_glyphs_count];
	}
	else {
		unsigned char		f_font_info_map[f_font_glyphs_count];
	}
};

A DefineFontInfo tag will be used to complete the definition of a DefineFont tag. It uses the exact same identifier (f_font_info_id_ref = f_font_id). You must have the corresponding font definition appearing before the DefineFontInfo since it will use the number of glyphs defined in the DefineFont to know the size of the map definition in the DefineFontInfo tag.

When it looks like it perfectly matches an existing system font, the plugin may use that system font (as long as no rotation is used, it will work fine.) It is also possible to force the use of the system font by declaring an empty DefineFont tag (i.e. no glyph declaration at all.)

The use of system fonts usually ensures a much better quality of smaller prints. However, since version 8, there are many features in the Flash player taking care of really small fonts.

Note, however, that a system font (also called a device font) cannot be rotated. Also, the scaling and translation of a system font does not always respect the exact position. It is likely that the font will be moved to the next pixel left or right to avoid blurriness. That means it will look quite jaggedly when slowly moving such text.

The f_font_info_wide flag must be set to 1 in version 6 and over.

Note that the flag f_font_info_small_text of version 7+ is the same bit as the flag f_font_info_unicode in SWF version 5 or less.

Since version 6, the font name has to be encoded in UTF-8 instead of whatever encoding you want. It is also suggested that you use the DefineFontInfo2 tag instead.

DefineFontName

Tag Info
Tag Number: 
88
Tag Type: 
Define
Tag Flash Version: 
9
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define the legal font name and copyright.

Tag Structure: 
struct swf_definefontname {
	swf_tag			f_tag;		/* 88 */
	unsigned short		f_font_name_id_ref;
	string			f_font_name_display_name;
	string			f_font_name_copyright;
};

A DefineFontName tag is used to complement the definition of a DefineFont tag. It uses the exact same id (f_font_name_id_ref = f_font_id). You must have the corresponding font definition appearing before the DefineFontName since it needs to be attached to the DefineFont tag.

The f_font_name_display_name is the legal name of a font. This name cannot be used to load a corresponding system font.

The f_font_name_copyright string represents the font license.

DefineMorphShape

Tag Info
Tag Number: 
46
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

This is similar to a sprite with a simple morphing between two shapes.

Tag Structure: 

Tag Structure: 
struct swf_defineshape {
	swf_tag				f_tag;		/* 2, 22, 32, 46, 83, or 84 */
	unsigned short			f_shape_id;
	swf_rect			f_rect;
	is_morph = f_tag == DefineMorphShape || f_tag == DefineMorphShape2;
	has_strokes = f_tag == DefineShape4 || f_tag == DefineMorphShape2;
	if(is_morph) {
		swf_rect			f_rect_morph;
	}
	if(has_strokes) {
		swf_rect			f_stroke_rect;
		if(is_morph) {
			swf_rect			f_stroke_rect_morph;
		}
		unsigned			f_define_shape_reserved : 6;
		unsigned			f_define_shape_non_scaling_strokes : 1;
		unsigned			f_define_shape_scaling_strokes : 1;
	}
	if(is_morph) {
		unsigned long			f_offset_morph;
		swf_morph_shape_with_style	f_morph_shape_with_style;
	}
	else {
		swf_shape_with_style		f_shape_with_style;
	}
};

These are probably the most important tags in this reference. They are used to define a shape using Bezier curves and lines with different styles. The DefineShape of V1.0 is usually enough unless you need a large number of styles or you want to specify colors with an alpha channel (RGBA).

The DefineMorphShape and DefineMorphShape2 can be used to render an intermediate shape between two defined shapes. All the points and control points of both shapes must match. This is because the rendering of the morphing shapes is just an interpolation between both shapes points and control points positions. The interpolation is a very simple linear function (note however that you still can use a non-linear transformation effect in the end.) Most of the parameters in a shape definition are doubled when this tag is used. It otherwise looks very similar.

The f_stroke_rect and f_stroke_rect_morph rectangles define the boundaries around their respective shapes without the line strokes (excluding the thickness of the line.)

The f_define_shape_non_scaling_strokes flag should be set to 1 if at least one of the line strokes always stays the same while morphing.

The f_define_shape_scaling_strokes flag should be set to 1 if at least one of the line strokes is changing while morphing.

The f_offset_morph 32 bits value gives the offset from after that value to the start of the second shape (the shape to morph to.) In other words, this value can be used to skip the styles and the first shape at once.

DefineMorphShape2

Tag Info
Tag Number: 
84
Tag Type: 
Define
Tag Flash Version: 
8
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Declare a morphing shape with attributes supported by version 8+.

Tag Structure: 

Tag Structure: 
struct swf_defineshape {
	swf_tag				f_tag;		/* 2, 22, 32, 46, 83, or 84 */
	unsigned short			f_shape_id;
	swf_rect			f_rect;
	is_morph = f_tag == DefineMorphShape || f_tag == DefineMorphShape2;
	has_strokes = f_tag == DefineShape4 || f_tag == DefineMorphShape2;
	if(is_morph) {
		swf_rect			f_rect_morph;
	}
	if(has_strokes) {
		swf_rect			f_stroke_rect;
		if(is_morph) {
			swf_rect			f_stroke_rect_morph;
		}
		unsigned			f_define_shape_reserved : 6;
		unsigned			f_define_shape_non_scaling_strokes : 1;
		unsigned			f_define_shape_scaling_strokes : 1;
	}
	if(is_morph) {
		unsigned long			f_offset_morph;
		swf_morph_shape_with_style	f_morph_shape_with_style;
	}
	else {
		swf_shape_with_style		f_shape_with_style;
	}
};

These are probably the most important tags in this reference. They are used to define a shape using Bezier curves and lines with different styles. The DefineShape of V1.0 is usually enough unless you need a large number of styles or you want to specify colors with an alpha channel (RGBA).

The DefineMorphShape and DefineMorphShape2 can be used to render an intermediate shape between two defined shapes. All the points and control points of both shapes must match. This is because the rendering of the morphing shapes is just an interpolation between both shapes points and control points positions. The interpolation is a very simple linear function (note however that you still can use a non-linear transformation effect in the end.) Most of the parameters in a shape definition are doubled when this tag is used. It otherwise looks very similar.

The f_stroke_rect and f_stroke_rect_morph rectangles define the boundaries around their respective shapes without the line strokes (excluding the thickness of the line.)

The f_define_shape_non_scaling_strokes flag should be set to 1 if at least one of the line strokes always stays the same while morphing.

The f_define_shape_scaling_strokes flag should be set to 1 if at least one of the line strokes is changing while morphing.

The f_offset_morph 32 bits value gives the offset from after that value to the start of the second shape (the shape to morph to.) In other words, this value can be used to skip the styles and the first shape at once.

DefineScalingGrid

Tag Info
Tag Number: 
78
Tag Type: 
Define
Tag Flash Version: 
8
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define scale factors for a window, a button, or other similar objects.

Tag Structure: 
struct swf_definescalinggrid {
	swf_tag				f_tag;		/* 78 */
	unsigned short			f_button_id_ref;
	swf_rect			f_rect;
};

This definition is used so the scaling factors applied on an object affects only the center of the object fully. The borders are only affected in one direction and the corners are not scaled (note, restrictions apply, see below.) This is quite useful to draw a scalable button or window.


Fig 1 — Sample button being scaled with a scaling grid

As we can see in the example, the corners are not being scaled. The vertical borders are scaled vertically only. The horizontal borders are scaled horizontally only. The inner area is scaled both ways.

For your grid to work, there are many restrictions as follow:

  • The referenced object must be a DefineSprite or a DefineButton. Note that any button tag is affected.
  • The referenced object cannot be rotated or skewed. However, it is possible to include the resulting object in a sprite and then use a rotation or skew in the PlaceObject matrix when placing that sprite.
  • Shapes directly defined in the referenced object are affected. If you create a button or sprite made up of sub-sprites, these sub-sprites are not affected.
  • Text is not affected by the grid. It is always scaled as expected.
  • Fills are likely to not work as expected (i.e. bitmaps, images); that is, this tag is likely to have no effect on them
  • When scaling down so much that the inner area represents less than 1 pixel will then affect the borders and corners as if there wasn't a scaling grid.
  • Somehow the Stop action can prevent the grid from working (i.e. insert Shapes, Button, Grid, Action Stop, Resize, Show Frame; the edges are resized as if no grid was there.)
  • [would need more testing] It may be that to work you need to place the resulting button or sprite in another parent sprite. This is how I could make my grid work properly without having to mess around.

The f_button_id_ref needs to specify a button or a sprite.

The f_rect defines the inner area.

DefineSceneAndFrameData

Tag Info
Tag Number: 
86
Tag Type: 
Define
Tag Flash Version: 
9
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define raw data for scenes and frames.

Tag Structure: 
struct swf_definesceneandframedata {
	swf_tag				f_tag;		/* 86 */
	unsigned char			f_data[tag size];
};

This tag is used to define some raw data for a scene and frame. It is often used to include XML files in Flash animations.

f_data is an array of bytes.

DefineShape

Tag Info
Tag Number: 
2
Tag Type: 
Define
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define a simple geometric shape.

Tag Structure: 
struct swf_defineshape {
	swf_tag				f_tag;		/* 2, 22, 32, 46, 83, or 84 */
	unsigned short			f_shape_id;
	swf_rect			f_rect;
	is_morph = f_tag == DefineMorphShape || f_tag == DefineMorphShape2;
	has_strokes = f_tag == DefineShape4 || f_tag == DefineMorphShape2;
	if(is_morph) {
		swf_rect			f_rect_morph;
	}
	if(has_strokes) {
		swf_rect			f_stroke_rect;
		if(is_morph) {
			swf_rect			f_stroke_rect_morph;
		}
		unsigned			f_define_shape_reserved : 6;
		unsigned			f_define_shape_non_scaling_strokes : 1;
		unsigned			f_define_shape_scaling_strokes : 1;
	}
	if(is_morph) {
		unsigned long			f_offset_morph;
		swf_morph_shape_with_style	f_morph_shape_with_style;
	}
	else {
		swf_shape_with_style		f_shape_with_style;
	}
};

These are probably the most important tags in this reference. They are used to define a shape using Bezier curves and lines with different styles. The DefineShape of V1.0 is usually enough unless you need a large number of styles or you want to specify colors with an alpha channel (RGBA).

The DefineMorphShape and DefineMorphShape2 can be used to render an intermediate shape between two defined shapes. All the points and control points of both shapes must match. This is because the rendering of the morphing shapes is just an interpolation between both shapes points and control points positions. The interpolation is a very simple linear function (note however that you still can use a non-linear transformation effect in the end.) Most of the parameters in a shape definition are doubled when this tag is used. It otherwise looks very similar.

The f_stroke_rect and f_stroke_rect_morph rectangles define the boundaries around their respective shapes without the line strokes (excluding the thickness of the line.)

The f_define_shape_non_scaling_strokes flag should be set to 1 if at least one of the line strokes always stays the same while morphing.

The f_define_shape_scaling_strokes flag should be set to 1 if at least one of the line strokes is changing while morphing.

The f_offset_morph 32 bits value gives the offset from after that value to the start of the second shape (the shape to morph to.) In other words, this value can be used to skip the styles and the first shape at once.

DefineShape2

Tag Info
Tag Number: 
22
Tag Type: 
Define
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Brief Description: 

Define a simple geometric shape.

Tag Structure: 

Tag Structure: 
struct swf_defineshape {
	swf_tag				f_tag;		/* 2, 22, 32, 46, 83, or 84 */
	unsigned short			f_shape_id;
	swf_rect			f_rect;
	is_morph = f_tag == DefineMorphShape || f_tag == DefineMorphShape2;
	has_strokes = f_tag == DefineShape4 || f_tag == DefineMorphShape2;
	if(is_morph) {
		swf_rect			f_rect_morph;
	}
	if(has_strokes) {
		swf_rect			f_stroke_rect;
		if(is_morph) {
			swf_rect			f_stroke_rect_morph;
		}
		unsigned			f_define_shape_reserved : 6;
		unsigned			f_define_shape_non_scaling_strokes : 1;
		unsigned			f_define_shape_scaling_strokes : 1;
	}
	if(is_morph) {
		unsigned long			f_offset_morph;
		swf_morph_shape_with_style	f_morph_shape_with_style;
	}
	else {
		swf_shape_with_style		f_shape_with_style;
	}
};

These are probably the most important tags in this reference. They are used to define a shape using Bezier curves and lines with different styles. The DefineShape of V1.0 is usually enough unless you need a large number of styles or you want to specify colors with an alpha channel (RGBA).

The DefineMorphShape and DefineMorphShape2 can be used to render an intermediate shape between two defined shapes. All the points and control points of both shapes must match. This is because the rendering of the morphing shapes is just an interpolation between both shapes points and control points positions. The interpolation is a very simple linear function (note however that you still can use a non-linear transformation effect in the end.) Most of the parameters in a shape definition are doubled when this tag is used. It otherwise looks very similar.

The f_stroke_rect and f_stroke_rect_morph rectangles define the boundaries around their respective shapes without the line strokes (excluding the thickness of the line.)

The f_define_shape_non_scaling_strokes flag should be set to 1 if at least one of the line strokes always stays the same while morphing.

The f_define_shape_scaling_strokes flag should be set to 1 if at least one of the line strokes is changing while morphing.

The f_offset_morph 32 bits value gives the offset from after that value to the start of the second shape (the shape to morph to.) In other words, this value can be used to skip the styles and the first shape at once.

DefineShape3

Tag Info
Tag Number: 
32
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Brief Description: 

Define a simple geometric shape.

Tag Structure: 

Tag Structure: 
struct swf_defineshape {
	swf_tag				f_tag;		/* 2, 22, 32, 46, 83, or 84 */
	unsigned short			f_shape_id;
	swf_rect			f_rect;
	is_morph = f_tag == DefineMorphShape || f_tag == DefineMorphShape2;
	has_strokes = f_tag == DefineShape4 || f_tag == DefineMorphShape2;
	if(is_morph) {
		swf_rect			f_rect_morph;
	}
	if(has_strokes) {
		swf_rect			f_stroke_rect;
		if(is_morph) {
			swf_rect			f_stroke_rect_morph;
		}
		unsigned			f_define_shape_reserved : 6;
		unsigned			f_define_shape_non_scaling_strokes : 1;
		unsigned			f_define_shape_scaling_strokes : 1;
	}
	if(is_morph) {
		unsigned long			f_offset_morph;
		swf_morph_shape_with_style	f_morph_shape_with_style;
	}
	else {
		swf_shape_with_style		f_shape_with_style;
	}
};

These are probably the most important tags in this reference. They are used to define a shape using Bezier curves and lines with different styles. The DefineShape of V1.0 is usually enough unless you need a large number of styles or you want to specify colors with an alpha channel (RGBA).

The DefineMorphShape and DefineMorphShape2 can be used to render an intermediate shape between two defined shapes. All the points and control points of both shapes must match. This is because the rendering of the morphing shapes is just an interpolation between both shapes points and control points positions. The interpolation is a very simple linear function (note however that you still can use a non-linear transformation effect in the end.) Most of the parameters in a shape definition are doubled when this tag is used. It otherwise looks very similar.

The f_stroke_rect and f_stroke_rect_morph rectangles define the boundaries around their respective shapes without the line strokes (excluding the thickness of the line.)

The f_define_shape_non_scaling_strokes flag should be set to 1 if at least one of the line strokes always stays the same while morphing.

The f_define_shape_scaling_strokes flag should be set to 1 if at least one of the line strokes is changing while morphing.

The f_offset_morph 32 bits value gives the offset from after that value to the start of the second shape (the shape to morph to.) In other words, this value can be used to skip the styles and the first shape at once.

DefineShape4

Tag Info
Tag Number: 
83
Tag Type: 
Define
Tag Flash Version: 
8
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Declare a shape which supports new line caps, scaling and fill options.

Tag Structure: 

Tag Structure: 
struct swf_defineshape {
	swf_tag				f_tag;		/* 2, 22, 32, 46, 83, or 84 */
	unsigned short			f_shape_id;
	swf_rect			f_rect;
	is_morph = f_tag == DefineMorphShape || f_tag == DefineMorphShape2;
	has_strokes = f_tag == DefineShape4 || f_tag == DefineMorphShape2;
	if(is_morph) {
		swf_rect			f_rect_morph;
	}
	if(has_strokes) {
		swf_rect			f_stroke_rect;
		if(is_morph) {
			swf_rect			f_stroke_rect_morph;
		}
		unsigned			f_define_shape_reserved : 6;
		unsigned			f_define_shape_non_scaling_strokes : 1;
		unsigned			f_define_shape_scaling_strokes : 1;
	}
	if(is_morph) {
		unsigned long			f_offset_morph;
		swf_morph_shape_with_style	f_morph_shape_with_style;
	}
	else {
		swf_shape_with_style		f_shape_with_style;
	}
};

These are probably the most important tags in this reference. They are used to define a shape using Bezier curves and lines with different styles. The DefineShape of V1.0 is usually enough unless you need a large number of styles or you want to specify colors with an alpha channel (RGBA).

The DefineMorphShape and DefineMorphShape2 can be used to render an intermediate shape between two defined shapes. All the points and control points of both shapes must match. This is because the rendering of the morphing shapes is just an interpolation between both shapes points and control points positions. The interpolation is a very simple linear function (note however that you still can use a non-linear transformation effect in the end.) Most of the parameters in a shape definition are doubled when this tag is used. It otherwise looks very similar.

The f_stroke_rect and f_stroke_rect_morph rectangles define the boundaries around their respective shapes without the line strokes (excluding the thickness of the line.)

The f_define_shape_non_scaling_strokes flag should be set to 1 if at least one of the line strokes always stays the same while morphing.

The f_define_shape_scaling_strokes flag should be set to 1 if at least one of the line strokes is changing while morphing.

The f_offset_morph 32 bits value gives the offset from after that value to the start of the second shape (the shape to morph to.) In other words, this value can be used to skip the styles and the first shape at once.

DefineSound

Tag Info
Tag Number: 
14
Tag Type: 
Define
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Declare a sound effect. This tag defines sound samples that can later be played back using either a StartSound or a DefineButtonSound. Note that the same DefineSound block can actually include multiple sound files and only part of the entire sound can be played back as required.

Tag Structure: 
struct swf_definesound {
	swf_tag			f_tag;		/* 14 */
	unsigned short		f_sound_id;
	unsigned		f_sound_format : 4;
	unsigned		f_sound_rate : 2;
	unsigned		f_sound_is_16bits : 1;
	unsigned		f_sound_is_stereo : 1;
	unsigned long		f_sound_samples_count;
	unsigned char		f_sound_data[<variable size>];
};

A DefineSound tag declares a set of samples of a sound effect or a music.

The sound samples can be compressed or not, stereo or not and 8 or 16 bits. The different modes are not all available in version 2, although the same tag is used in newer versions with additional capabilities.

The f_sound_is_16bits is always set to 1 (16bits samples) if the samples are compressed (neither Rawnor Uncompressed).

The f_sound_rate represents the rate at which the samples are defined. The rate at which it will be played on the target computers may differ. The following equation can be used to determine the rate:

	rate = 5512.5 * 2 ** f_sound_rate

It yields the following values (the rate of 5512.5 is rounded down to 5512):

f_sound_rate Rate in
bytes per seconds
0 5512
1 11025
2 22050
3 44100

The f_sound_samples_count value is the exact number of samples not the size of the data in byte. Thus, in stereo, it represents the number of pairs. To know the byte size, use the total size of the tag minus the header (11 or 13 depending on whether the size of the tag is larger than 62 - it is more than likely that it will be 13).

The f_sound_format can be one of the following values:

Value Name Comment Version
0 Raw 16 bits uncompressed samples are not specified as being saved in little or big endian. The endianess of the processor on which the movie is being played will be used. Thus you should never use this format with 16 bits samples. 2
1 ADPCM Audio differential pulse code modulation compression scheme. 2
2 MP3 High ratio of compression with very good quality sound. Use MP3 if you can save a V4.x or better movie. 4
3 Uncompressed Uncompressed samples which are always saved in little endian. This is similar to the format 0 except you can be sure the data will be properly played on any system. 4
6 Nellymoser Good quality sound compression for voices. Use Nellymoser if you can save a V6.x or better movie and the sound is actually a voice or animal roar, squeek, etc. This is a single channel compression. 6

The f_sound_data depends on the sound format. The following describes the different formats as used in the DefineSound and the SoundStreamBlock tags.

  • 8 bits

8 bits data is saved in an array of signed char. The value 0 represents silence. The samples can otherwise have values between -128 and +127.

  • 16 bits

16 bits data is saved in an array of signed short. The value 0 represents silence. The samples can otherwise have values between -32768 and +32767. By default, the data will be encoded in little endian. However, the RAWformat doesn't specify the endianess of the data saved in that case. You should avoid using RAW16 bits data. Use Uncompresseddata instead, compress it in some of the available compression formats (including RAW8 bits data). A player may wish to avoid playing any sound saved in RAW16 bits to avoid any problem.

  • Mono

Mono sound saves only one channel of sound. It will be played back on both output (left and right) channels. This is often enough for most sound effects and voice.

  • Stereo

For better quality music and sound effects, you can save the data in stereo. In this case, the samples for each channel (left and right) are interleaved, with the data for the left channel first. Thus, you will have: LRLRLRLRLR... In 8 bit, you get one byte for the left channel, then one byte for the right, one for the left, one for the right, etc. In 16 bit, you get two bytes for the left then two for the right channel, etc.

  • Raw

The RAWencoding is an uncompressed endian unspecified encoding. You can use this format to safely save small 8 bits samples sound effects. For 16 bit sound effects, some system may not swap the data before playing it, although it is likely that the buffer is expected to be in little endian.

  • ADPCM

Audio differential pulse code modulation compression scheme. This is pretty good compression for sound effects.

The ADPCM tables used by the SWF players are as follow:

int swf_adpcm_2bits[ 2] = { -1,  2 };

int swf_adpcm_3bits[ 4] = { -1, -1,  2,  4 };

int swf_adpcm_4bits[ 8] = { -1, -1, -1, -1,  2,  4,  6,  8 };

int swf_adpcm_5bits[16] = { -1, -1, -1, -1, -1, -1, -1, -1,
                             1,  2,  4,  6,  8, 10, 13, 16 };

The ADPCM data is composed of a 2 bits encoding size (2 to 5 bits) and an array of 4096 left (mono) or left and right (stereo) samples.

	struct swf_adpcm_header {
		unsigned		f_encoding : 2;
	};

The number of bits for the compression is f_encoding + 2.

	struct swf_adpcm_mono {
		unsigned short		f_first_sample;
		unsigned		f_first_index : 6;
		unsigned		f_data[4096] : f_encoding + 2;
	};
	struct swf_adpcm_stereo {
		unsigned short		f_first_sample_left;
		unsigned		f_first_index_left : 6;
		unsigned short		f_first_sample_right;
		unsigned		f_first_index_right : 6;
		unsigned		f_data[8192] : f_encoding + 2;
	};
  • MP3

IMPORTANT LICENSING NOTES: please, see The entire SSWF project license above for information about the Audio MPEG licensing rights.

The SWF players which support movie v4.x and better will also support MPEG1 audio compression. This is a good quality high compression scheme. The players need to support constant and variable bit rates, and MPEG1 Layer 3, v2 and v2.5. For more information about MPEG you probably want to check out this web site: http://www.mp3-tech.org/.

In SWF movies, you need to save a seeking point (position of the data to play in a given frame) before the MP3 frames themselves. It is also called the initial latency. I will make this clearer once I understand better what it means.

An MP3 frame is described below. This is exactly what you will find in any music file.

	struct swf_mp3_header {
		unsigned		f_sync_word : 11;
		unsigned		f_version : 2;
		unsigned		f_layer : 2;
		unsigned		f_no_protection : 1;
		unsigned		f_bit_rate : 4;
		unsigned		f_sample_rate : 2;
		unsigned		f_padding : 1;
		unsigned		f_reserved : 1;
		unsigned		f_channel_mode : 2;
		unsigned		f_mode_extension : 2;
		unsigned		f_copyright : 1;
		unsigned		f_original : 1;
		unsigned		f_emphasis : 2;
		if(f_no_protection == 0) {
			unsigned short	f_check_sum;
		}
		unsigned char		f_data[variable size];
	};

The f_sync_word are 11 bits set to 1's only. This can be used to synchronize to the next frame without knowing the exact size of the previous frame.

The f_version can be one of the following:

  • 0 - MPEG version 2.5 (extension to MPEG 2)
  • 1 - reserved
  • 2 - MPEG version 2 (ISO/IEC 13818-3)
  • 3 - MPEG version 1 (ISO/IEC 11172-3)

Note: if the MPEG version 2.5 isn't use, then the f_sync_word can be viewed as 12 bits and the f_version as 1 bit.

In SWF movies, the f_layer must be set to III (which is 1). The valid MPEG layers are as follow:

  • 0 - reserved
  • 1 - Layer III
  • 2 - Layer II
  • 3 - Layer I

The f_no_protection determines whether a checksum is defined right after the 32 bits header. If there is a checksum, it is a 16 bit value which represents the total of all the words in the frame data.

The f_bit_rate determines the rate at which the following data shall be taken as. The version and layer have also an effect on determining what the rate is from this f_bit_rate value. Since SWF only accepts Layer III data, we can only accepts a few set of rates as follow. MP3 players (and thus SWF players) must support variable bit rates. Thus, each frame may use a different value for the f_bit_rate field.

f_bit_rate MPEG version 1 MPEG version 2
0 free(1) free(1)
1 32 kbps 8 kbps
2 40 kbps 16 kbps
3 48 kbps 24 kbps
4 56 kbps 32 kbps
5 64 kbps 40 kbps
6 80 kbps 48 kbps
7 96 kbps 56 kbps
8 112 kbps 64 kbps
9 128 kbps 80 kbps
10 160 kbps 96 kbps
11 192 kbps 112 kbps
12 224 kbps 128 kbps
13 256 kbps 144 kbps
14 320 kbps 160 kbps
15 bad(2) bad(2)
(1) free — means any (variable) bit rate
(2) bad — means you can't properly use this value

The f_sample_rate defines the rate at which the encoded samples will be played at. This rate may vary and be equal or smaller than the rate indicated in the DefineSound header. The rate definition depends on the MPEG version as follow:

f_sample_rate MPEG version 1 MPEG version 2 MPEG version 2.5
0 44100 Hz 22050 Hz 11025 Hz
1 48000 Hz 24000 Hz 12000 Hz
2 32000 Hz 15000 Hz 8000 Hz
3 reserved

The f_padding will be set to 1 if the stream includes pads (one extra slot - 8 bits of data). This is used to ensure that the sound is exactly the right size. Useful only if your sound is very long and synchronized with the images.

The f_reserved isn't used and must be set to zero in SWF files.

The f_channel_mode determines the mode used to compress stereophonic audio. Note that the Dual Channel mode is viewed as a stereo stream by SWF. It can be one of the following:

  • 0 - stereo (standard LRLRLR...)
  • 1 - joint stereo (L+R and L-R)
  • 2 - dual channels (LLLLL... and then RRRRR...)
  • 3 - single channel (monophonic audio)

The f_mode_extension determines whether the intensity stereo (L+R — bit 5) and middle side stereo (L-R — bit 4) are used (set bit to 1) or not (set bit to 0) in joint stereo. f_mode_extension is usually always set to 3.

The f_copyright field is a boolean value which specify whether the corresponding audio is copyrighted or not. The default is to set it to 1 (copyrighted).

The f_original field is a boolean value which specify whether the corresponding audio is a copy or the actual original sound track. It's usually set to 0 (a copy) in SWF movies.

The f_emphasis field can be one of the following values. It is rarely used. It tells the decoder to re-equalize the sounds.

  • 0 - no emphasis
  • 1 - 50/15 ms
  • 2 - reserved
  • 3 - CCIT J.17
  • Nellymoser

This is a newly supported scheme to encode speech (and audio) of either better quality or smaller bit rate. Thus you can either put more sound in your files resulting in a similar file size or make the entire file smaller so it downloads faster.

Somehow, the Nellymoser encoding and decoding patents used by Flash have been released. You may want to look at the mpeg project for information about the format. Feel free to check out the http://www.nellymoser.com web site for more info about this compression scheme.

DefineSprite

Tag Info
Tag Number: 
39
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Declares an animated character. This is similar to a shape with a display list so the character can be changing on its own over time.

Tag Structure: 
struct swf_definesprite {
	swf_tag			f_tag;		/* 39 */
	unsigned short		f_sprite_id;
	unsigned short		f_frame_count;
	...			<data>;
	swf_tag			f_end;
};

A sprite is a set of SWF tags defining an animated object which can then be used as a simple object. A sprite cannot contain another sprite. hHowever, you can use PlaceObject2 to place a sprite in another.

The following are the tags accepted in a Sprite:

DoAction
End
FrameLabel
PlaceObject
PlaceObject2
PlaceObject3
RemoveObject
RemoveObject2
ShowFrame
SoundStreamBlock
SoundStreamHead
SoundStreamHead2
StartSound

The data array of tags should always be terminated by an End tag though this can be inferred some players may not support a non-terminated list.

In order to initialize a sprite once, you can use the DoInitAction. This tag comes along (after) a DefineSprite tag and not inside it.

Note that in newer animations (since version 5,) it is possible to load a movie using an external link. Adobe calls them movies, although, really, once loaded, they are sprites. Those sprites can include all sorts of tags since it is the same as a complete Flash animation. The same concept is also available via ActionScript, i.e. you can create a new movie which in fact is a Sprite.

DefineText

Tag Info
Tag Number: 
11
Tag Type: 
Define
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Defines a text of characters displayed using a font. This definition doesn't support any transparency.

Tag Structure: 
struct swf_definetext {
	swf_tag			f_tag;		/* 11 or 33 */
	unsigned short		f_text_id;
	swf_rect		f_rect;
	swf_matrix		f_matrix;
	unsigned char		f_glyph_bits;
	unsigned char		f_advance_bits;
	swf_text_record		f_text_record;
};

Define an object of text so the SWF player can draw a string. The only difference between the DefineText and DefineText2 tags is that the latter supports RGBA colors. This can be seen in one of the swf_text_record structures.

Since version 8 it is possible to define extraneous parameters when defining a CSMTextSettings tag referencing a DefineText or DefineText2.

DefineText2

Tag Info
Tag Number: 
33
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Defines a text of characters displayed using a font. Transparency is supported with this tag.

Tag Structure: 

Tag Structure: 
struct swf_definetext {
	swf_tag			f_tag;		/* 11 or 33 */
	unsigned short		f_text_id;
	swf_rect		f_rect;
	swf_matrix		f_matrix;
	unsigned char		f_glyph_bits;
	unsigned char		f_advance_bits;
	swf_text_record		f_text_record;
};

Define an object of text so the SWF player can draw a string. The only difference between the DefineText and DefineText2 tags is that the latter supports RGBA colors. This can be seen in one of the swf_text_record structures.

Since version 8 it is possible to define extraneous parameters when defining a CSMTextSettings tag referencing a DefineText or DefineText2.

DefineTextFormat

Tag Info
Tag Number: 
42
Tag Type: 
Define
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

Another tag that Flash ended up not using.

Tag Structure: 

Unknown

This tag is not defined in the Flash documents. It should not be used in your movies.

DefineVideo

Tag Info
Tag Number: 
38
Tag Type: 
Define
Tag Flash Version: 
4
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

Apparently, Macromedia did have a first attempt in supporting video on their platform. It looks, however, as if they reconsidered at that point in time.

Tag Structure: 

Unknown

This tag is not defined anywhere.

DefineVideoStream

Tag Info
Tag Number: 
60
Tag Type: 
Define
Tag Flash Version: 
6
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Defines the necessary information for the player to display a video stream (i.e. size, codec, how to decode the data, etc.). Play the frames with VideoFrame tags.

Tag Structure: 
struct swf_definevideostream {
	swf_tag			f_tag;		/* 60 */
	unsigned short		f_video_id;
	unsigned short		f_frame_count;
	unsigned short		f_width;	/* WARNING: this is in pixels */
	unsigned short		f_height;
	unsigned char		f_reserved : 5;
	unsigned char		f_deblocking : 2;
	unsigned char		f_smoothing : 1;
	unsigned char		f_codec;
};

This tag defines a video stream. To playback the video stream, one needs to add a list of VideoFrame tags.

The f_width and f_height are defined in pixels. This is rather uncommon in SWF so it is to be noted multiple times.

The f_deblocking parameter can be set to one of the values defined in the following table. All videos are saved in small blocks of about 16x16 pixels (there are different sizes.) Turning this feature on lets the player mix colors between blocks for better output quality.

Number Comments SWF Version
0 Use video packet information 6
1 Always Off 6
2 Fast deblocking (in version 6 it meant: always on) 6
3 High Quality Deblocking 8
4 High Quality Deblocking and Fast Deringing 8
5 High Quality Deblocking and Deringing 8

The f_smoothing flag can be set to 1 to have the player smooth the video before rendering it on the output screen.

The f_codec number specifies the codec used to compress the video. At this time, the following are defined:

Number Name Comments SWF Version
2 Sorenson H.263 Since Adobe took over Flash, they worked on making this format free of any royalties. In other words, you are free to encode and decode this video format in your commercial Flash animations. 6
3 Screen Video   7
4 VP6   8
5 VP6 with Alpha   8


 

DoABC

Tag Info
Tag Number: 
82
Tag Type: 
Action
Tag Flash Version: 
9
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

New container tag for ActionScripts under SWF 9. Includes an identifier, a name and actions.

Tag Structure: 

Tag Structure: 
struct swf_doabc {
	swf_tag			f_tag;		/* 72 or 82 */
	if(f_tag == DoABC) {
		unsigned long	f_action_flags;
		string		f_action_name;
	}
	swf_action3		f_action_record[variable];
};

*the version specified here is the version in which the tags appeared—however, actions of higher versions can be used with older version tags and thus this version doesn't indicate the version of all the actions used in this tag

The DoABC and DoABCDefine are available since version 9. These are similar to the old DoAction and DoInitAction, yet the actions use a way different declaration scheme and they include flags and a name. This new scheme helps greatly in simplifying the definitions of ECMAScript classes and accelerate the access to the code tremendously.

Note that the f_allow_abc bit of the FileAttributes flags must be set for the ABC actions to work at all.

The following describes the data in the DoABC and DoABCDefine tags. Note that at this point the DoABCDefine tag is not available, probably because you can do the same thing with a DoABC.

The f_action_flags define one bit at this point: bit 0 is kDoAbcLazyInitializeFlag. All the other bits must be set to zero to ensure forward compatibility. The lazy initialization bit is used to determine whether the DoABC tag is in place (execute as encountered) or callbacks (execute as it is referenced by other scripts.)

The f_action_name represents the name of this action script in case of a DoABC.

In some document, it mentioned that it would represent the name of a class when the DoAction3Instantiate tag is used. However, that tag is not implemented yet if ever.

The f_action_record is a buffer of action script version 3. It is different from the DoAction action script and is called the ABC script.

At this time, the swf_action3 is badly documented in the abcFormat.html file. There are now much better documents about this format on the Mozilla website.

DoABCDefine

Tag Info
Tag Number: 
72
Tag Type: 
Action
Tag Flash Version: 
9
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

New container tag for ActionScripts under SWF 9. Includes only actions. This tag is not defined in the official Flash documentation.

Tag Structure: 
struct swf_doabc {
	swf_tag			f_tag;		/* 72 or 82 */
	if(f_tag == DoABC) {
		unsigned long	f_action_flags;
		string		f_action_name;
	}
	swf_action3		f_action_record[variable];
};

*the version specified here is the version in which the tags appeared—however, actions of higher versions can be used with older version tags and thus this version doesn't indicate the version of all the actions used in this tag

The DoABC and DoABCDefine are available since version 9. These are similar to the old DoAction and DoInitAction, yet the actions use a way different declaration scheme and they include flags and a name. This new scheme helps greatly in simplifying the definitions of ECMAScript classes and accelerate the access to the code tremendously.

Note that the f_allow_abc bit of the FileAttributes flags must be set for the ABC actions to work at all.

The following describes the data in the DoABC and DoABCDefine tags. Note that at this point the DoABCDefine tag is not available, probably because you can do the same thing with a DoABC.

The f_action_flags define one bit at this point: bit 0 is kDoAbcLazyInitializeFlag. All the other bits must be set to zero to ensure forward compatibility. The lazy initialization bit is used to determine whether the DoABC tag is in place (execute as encountered) or callbacks (execute as it is referenced by other scripts.)

The f_action_name represents the name of this action script in case of a DoABC.

In some document, it mentioned that it would represent the name of a class when the DoAction3Instantiate tag is used. However, that tag is not implemented yet if ever.

The f_action_record is a buffer of action script version 3. It is different from the DoAction action script and is called the ABC script.

At this time, the swf_action3 is badly documented in the abcFormat.html file. There are now much better documents about this format on the Mozilla website.

DoAction

Tag Info
Tag Number: 
12
Tag Type: 
Action
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Actions to perform at the time the next show frame is reached and before the result is being displayed. It can duplicate sprites, start/stop movie clips, etc.

All the actions within a frame are executed sequentially in the order they are defined.

Important: many actions are not supported in Adobe Flash version 1. Please, see the reference of actions below in order to know which actions can be used with which version of Adobe Flash.

Tag Structure: 
struct swf_doaction {
	swf_tag			f_tag;		/* 12 and 59 */
	if(f_tag == DoInitAction) {
		unsigned short	f_action_sprite;
	}
	swf_action		f_action_record[variable];
};

The DoAction tag will be used to execute a set of actions in place. Usually, actions are used on buttons to add interactivity to the SWF movies. In version 1 you had only one dynamic branch (WaitForFrame). In version 4 you can test many different things such as a position, angle or sound track cursor position. Since version 5, SWF has a complete scripting language supporting string and arithmetic operations.

The DoInitAction tag is used when a sprite needs to be initialized. These actions are carried on the sprite only once. These are outside of the given sprite and will reference the sprite so all the actions are automatically applied to the sprite without you having to do a SetTarget.

The following describes the data in the DoAction and DoInitAction tags:

The f_action_sprite is a reference (identifier) to the sprite which will be initialized with the given actions.

The f_action_record is an array of actions terminated by an End action.

The following is a list of all the actions supported by SWF format. The Version tells you what version of Flash player you need in order to use the given action (otherwise it is likely to be ignored or worse, make the player crash). Note that Macromedia defines all the actions as being part of version 3 and over. Thus, any action mark as being available in earlier versions (version 1 or 2) may in fact not be (though the DoAction and DefineButton tags were part of version 1!!!)

The Length (Stacked) column specifies the length of the data following the property (only with the action ID is 0x80 to 0xFF) and what will be pushed onto the stack. All the expressions work as in polish notation: push the parameters, then execute an order that uses the data from the stack. The actions that do not push anything on the stack have nothing written between parenthesis.

The Data & Operation column specifies what data follows the action and what the operation is. If there is no data and no operation, then n.a. is used. The data will be described as a list of fields as in the other structures described in this document. The operations will be written as closely as possible to a C like operation (though strings are managed in a much different way than C!) Anything which is popped from the stack will be given a letter and a digit. The digit represents the count or position and the letter the type of the data (a count of 1 represents the first pop, a count of 2 represents the second pop, etc.) The following column (Comments) will explain how the operation uses the data when appropriate.

The data types used are as follow:

    Short Type
    a any type
    b boolean
    f foat
    i integer
    n(1) numeric (integer or float)
    o(2) object (as in C++)
    s string
    t array or table of values
    v variable - pushes multiple values on the stack

    (1) when I don't know whether an integer or a float should be specified I will use 'n' as well. This should be correct most of the time anyway.
    (2) an object reference can be obtained by evaluating the name of that object; thus GetVariable("carrot") will return a reference to the carrot object.

The following lists all the actions by name. Those that have the comment (typed) operates taking the type of its arguments in account as defined in ECMA-262 Section 11.6.1 (arithmetic), 11.8.5 (comparison), 11.9.3 (equality) which you can certainly find somewhere on the Internet. Version 3 is available here: ECMA-262 V3.0. The functions which are not typed will behave by (1) trying to transform parameters in values, then perform the operation with numbers only or (2) when strings cannot be transformed in values, perform a string operation.

DoInitAction

Tag Info
Tag Number: 
59
Tag Type: 
Action
Tag Flash Version: 
6
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Actions to perform the first time the following Show Frame tag is reached. All the initialization actions are executed before any other actions. You have to specify a sprite to which the actions are applied to. Thus you don't need a set target action. When multiple initialization action blocks are within the same frame, they are executed one after another in the order they appear in that frame.

Tag Structure: 

Tag Structure: 
struct swf_doaction {
	swf_tag			f_tag;		/* 12 and 59 */
	if(f_tag == DoInitAction) {
		unsigned short	f_action_sprite;
	}
	swf_action		f_action_record[variable];
};

The DoAction tag will be used to execute a set of actions in place. Usually, actions are used on buttons to add interactivity to the SWF movies. In version 1 you had only one dynamic branch (WaitForFrame). In version 4 you can test many different things such as a position, angle or sound track cursor position. Since version 5, SWF has a complete scripting language supporting string and arithmetic operations.

The DoInitAction tag is used when a sprite needs to be initialized. These actions are carried on the sprite only once. These are outside of the given sprite and will reference the sprite so all the actions are automatically applied to the sprite without you having to do a SetTarget.

The following describes the data in the DoAction and DoInitAction tags:

The f_action_sprite is a reference (identifier) to the sprite which will be initialized with the given actions.

The f_action_record is an array of actions terminated by an End action.

The following is a list of all the actions supported by SWF format. The Version tells you what version of Flash player you need in order to use the given action (otherwise it is likely to be ignored or worse, make the player crash). Note that Macromedia defines all the actions as being part of version 3 and over. Thus, any action mark as being available in earlier versions (version 1 or 2) may in fact not be (though the DoAction and DefineButton tags were part of version 1!!!)

The Length (Stacked) column specifies the length of the data following the property (only with the action ID is 0x80 to 0xFF) and what will be pushed onto the stack. All the expressions work as in polish notation: push the parameters, then execute an order that uses the data from the stack. The actions that do not push anything on the stack have nothing written between parenthesis.

The Data & Operation column specifies what data follows the action and what the operation is. If there is no data and no operation, then n.a. is used. The data will be described as a list of fields as in the other structures described in this document. The operations will be written as closely as possible to a C like operation (though strings are managed in a much different way than C!) Anything which is popped from the stack will be given a letter and a digit. The digit represents the count or position and the letter the type of the data (a count of 1 represents the first pop, a count of 2 represents the second pop, etc.) The following column (Comments) will explain how the operation uses the data when appropriate.

The data types used are as follow:

    Short Type
    a any type
    b boolean
    f foat
    i integer
    n(1) numeric (integer or float)
    o(2) object (as in C++)
    s string
    t array or table of values
    v variable - pushes multiple values on the stack

    (1) when I don't know whether an integer or a float should be specified I will use 'n' as well. This should be correct most of the time anyway.
    (2) an object reference can be obtained by evaluating the name of that object; thus GetVariable("carrot") will return a reference to the carrot object.

The following lists all the actions by name. Those that have the comment (typed) operates taking the type of its arguments in account as defined in ECMA-262 Section 11.6.1 (arithmetic), 11.8.5 (comparison), 11.9.3 (equality) which you can certainly find somewhere on the Internet. Version 3 is available here: ECMA-262 V3.0. The functions which are not typed will behave by (1) trying to transform parameters in values, then perform the operation with numbers only or (2) when strings cannot be transformed in values, perform a string operation.

EnableDebugger

Tag Info
Tag Number: 
58
Tag Type: 
Format
Tag Flash Version: 
5
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

The data of this tag is an MD5 password like the EnableDebugger2 tag. When it exists and you know the password, you will be given the right to debug the movie with Flash V5.x and higher.

WARNING: this tag is only valid in Flash V5.x, use the EnableDebugger2 instead in V6.x and newer movies and Protect in older movies (V2.x, V3.x, and V4.x).

Tag Structure: 

Tag Structure: 
struct swf_protect {
	swf_tag			f_tag;		/* 24, 58 or 64  */
	if(version >= 5) {
		if(tag == ProtectDebug2) {
			unsigned short	f_reserved;1
		}
		/* the password is optional when tag == Protect */
		string		f_md5_password;
	}
};
  • 1. f_reserved must be set to zero.

See Also: 

The protection tag is totally useless. The SWF format is an open format, otherwise how would you have so many players and tools to work with SWF movies? Thus, you can pretend to protect your movies, but anyone with a simple binary editor can transform the tag and make it another which has no such effect. Also, swf_dump and some other tools (such as flasm) can read your movie anyway.

For the sake of defining what you have in each tag, there are the protection tags fully described.

According to Macromedia, you can find some free implementation of the MD5 algorithm by Poul-Henning Kamp in FreeBSD in the file src/lib/libcrypt/crypt-md5.c. For your convenience, there is an implementation of that MD5 sum in the SSWF library.

IMPORTANT

Version 2, 3, 4 must use Protect.

Version 5 must use EnableDebugger.

Version 6 and over must use EnableDebugger2.

EnableDebugger2

Tag Info
Tag Number: 
64
Tag Type: 
Format
Tag Flash Version: 
6
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

The data of this tag is a 16 bits word followed by an MD5 password like the EnableDebugger tag. When it exists and you know the password, you will be given the right to debug the movie with Flash V6.x and over.

WARNING: this tag is only valid in Flash V6.x and over, use the EnableDebugger instead in V5.x and Protect in older movies (V2.x, V3.x, and V4.x).

Tag Structure: 

Tag Structure: 
struct swf_protect {
	swf_tag			f_tag;		/* 24, 58 or 64  */
	if(version >= 5) {
		if(tag == ProtectDebug2) {
			unsigned short	f_reserved;1
		}
		/* the password is optional when tag == Protect */
		string		f_md5_password;
	}
};
  • 1. f_reserved must be set to zero.

See Also: 

The protection tag is totally useless. The SWF format is an open format, otherwise how would you have so many players and tools to work with SWF movies? Thus, you can pretend to protect your movies, but anyone with a simple binary editor can transform the tag and make it another which has no such effect. Also, swf_dump and some other tools (such as flasm) can read your movie anyway.

For the sake of defining what you have in each tag, there are the protection tags fully described.

According to Macromedia, you can find some free implementation of the MD5 algorithm by Poul-Henning Kamp in FreeBSD in the file src/lib/libcrypt/crypt-md5.c. For your convenience, there is an implementation of that MD5 sum in the SSWF library.

IMPORTANT

Version 2, 3, 4 must use Protect.

Version 5 must use EnableDebugger.

Version 6 and over must use EnableDebugger2.

End

Tag Info
Tag Number: 
0
Tag Type: 
Format
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Mark the end of the file or a Sprite. It can't appear anywhere else but the end of the file or a Sprite.

Tag Structure: 
struct swf_export {
	swf_tag			f_tag;		/* 0 */
};

The End tag marks the end of a sequence of tags. It is used to end the whole movie and to end the sequence of tags in a DefineSprite. The tag is composed just of the tag id.

Export

Tag Info
Tag Number: 
56
Tag Type: 
Define
Tag Flash Version: 
5
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Exports a list of definitions declared external so they can be used in other movies. You can in this way create one or more movies to hold a collection of objects to be reused by other movies without having to duplicate these in each movie. A single export is enough for an entire movie (and you should have just one).

Tag Structure: 
struct swf_export {
	swf_tag			f_tag;		/* 56 */
	unsigned short		f_count;
	swf_external		f_symbol[f_count];
};

The Export tag works in conjunction with the Import and Import2 tags. The Export tag gives a list of definitions made visible to the external world. Thus these definitions are in effect available to be imported by other movies.

The Export tag is a list of identifiers which are the identifiers of the objects defined within this movie and gives an external name to that object. The name is the external reference and that's what the Player will use to know how to retrieve the data from another movie. Each name need to be different, however there is no other restriction.

There should be only one Export per SWF movie. It is not clearly defined anywhere, but it is likely that the player will stop at the first export they find and not try to see if other Exports are defined in your SWF movies. It is not clear whether a movie using Export can itself Import other movies yet it is likely.

You should at least have one external reference (i.e. f_count > 0).

The identifiers defined in this list must match an object in the movie which includes this tag.

ExternalFont

Tag Info
Tag Number: 
52
Tag Type: 
Define
Tag Flash Version: 
5
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

It looks like accessing a system font was going to be another tag, but instead Macromedia made use of a flag in the existing DefineFont2 tag.

Tag Structure: 

Unknown

Unknown

File Header

Tag Info
Tag Number: 
-1
Tag Type: 
Format
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Although it isn't a tag per say, we consider the file header as being a tag because it represents a block in the flash file. Since version 8, it can be complemented by the FileAttributes tag.

Tag Structure: 
struct swf_header {1
	unsigned char		f_magic[3];	/* 'FWS' or 'CWS' */
	unsigned char		f_version;
	unsigned long		f_file_length;
}

struct swf_header_movie {2
	swf_rect		f_frame_size;
	unsigned short fixed	f_frame_rate;
	unsigned short		f_frame_count;
};
  • 1. This part is never compressed
  • 2. Although considered part of the header, this part is compressed in the 'CWS' format.

The file header is found at the very beginning of the file. It should be used to determine whether a file is an SWF file or not. Also, it contains information about the frame size, the speed at which is should be played and the version (determining the tags and actions possibly used in the file).

The f_magic[3] array is defined as the characters: 'FWS' (it is going backward probably because it was supposed to be read in a little endian as a long word). A movie can be compressed when the version is set to 6 or more. In this case, the magic characters are: 'CWS'.

The f_version is a value from 1 to 10 (the maximum at time of writing, the maximum will continue to increase).

The f_file_length is exactly what it says. That's useful for all these network connections which don't give you the size of the file. In case of a compressed movie, this is the total length of the uncompressed movie (useful to allocate the destination buffer for zlib).

The f_frame_size is a rectangle definition in TWIPS used to set the size of the frame on the screen. The minx and miny are usually not necessary in this rectangle definition.

The parameter in the swf_header_movie structure are part of the buffer that gets compressed in a movie (in other words, only the very first 8 bytes of the resulting file aren't compressed).

The f_frame_rate is a fixed value of 8.8 bits. It represents the number of frames per second the movie should be played at. Since version 8 of SWF, it is defined as an unsigned short fixed point value instead of an unsigned short. The lower 8 bits should always be zero (see comment below.) This value should never be set to zero in older versions. Newer versions use the value zero as "run at full speed" (which probably means run synchronized to the video screen Vertical BLank or VBL.)

The f_frame_count is a counter representing the number of SHOW FRAME within a movie. Most of the tools will compute this number automatically and it can usually be wrong and the movie will still play just fine.

FileAttributes

Tag Info
Tag Number: 
69
Tag Type: 
Format
Tag Flash Version: 
8
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Since version 8, this tag is required and needs to be the very first tag in the movie. It is used as a way to better handle security within the Flash Player.

Tag Structure: 
struct swf_fileattributes {
	swf_tag			f_tag;		/* 69 */
	unsigned		f_reserved : 3;
	unsigned		f_has_metadata : 1;
	unsigned		f_allow_abc : 1;	/* since V9.0 */
	unsigned		f_suppress_cross_domain_caching : 1;	/* since V9.0 */
	unsigned		f_swf_relative_urls : 1;	/* since V9.0 */
	unsigned		f_use_network : 1;
	unsigned		f_reserved : 24;
};

The FileAttributes tag is new to version 8. It must be present in all movies version 8 and over. It must be the very first tag in the SWF movie. It should be unique (other instances will be ignored.)

The f_has_metadata flag shall be set to 1 whenever the movie includes a Metadata tag.

The f_allow_abc flag shall be set to 1 to give the player the right to execute DoABC scripts (this is a version 9 flag, in version 8, keep it set to 0.)

The f_suppress_cross_domain_caching must have some effect over the caching of some things... (version 9+)

The f_swf_relative_urls means that URLs specified in the movie are relative to the URL where the movie was loaded from. (version 9+)

The f_use_network flag needs to be set to 1 in order for the movie to be given the right to access the network. By default, a local movie will be allowed to load other local movies but nothing from the network.

NOTES

I'm not registered as a security expert. However, this tag does not solve any security issues. It is a mimic just like the Protect, ProtectDebug and ProtectDebug2 tags. If you are playing a flash animation from a hacker, the fact is that it can include anything it wants and hack your system if the player has a flaw. Only a player without any flaws will be safe.

FrameLabel

Tag Info
Tag Number: 
43
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Names a frame or anchor. This frame can later be referenced using this name.

Tag Structure: 
struct swf_framelabel {
	swf_tag			f_tag;		/* 43 */
	string			f_label;
	if(version >= 6) {
		/* optional field */
		unsigned short	f_flags;
	}
};

The FrameLabel tag gives a textual name to a frame. This name can also be used as an anchor in V6.x+ and whenever specified in this way.

At this time, the optional field f_flags must be set to 1 if present. This means it has to be used as an anchor when the URL to the SWF movie includes a #<frame label> at the end.

The f_label is a null terminated string.

FreeAll

Tag Info
Tag Number: 
31
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

Probably an action that would be used to clear everything out.

Tag Structure: 

Unknown

This is an interesting concept: have a tag that can clear everything that we have done so far and start over. If you have a single time line, this is certainly useful. Since version 3, however, we get the DefineSprite tag that has a very similar capability (except that it does not have the ability to delete anything from memory, this comes in version 5 with access to external animations that can be created and thrown away dynamically.)

FreeCharacter

Tag Info
Tag Number: 
3
Tag Type: 
Define
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

Release a character which won't be used in this movie anymore.

Tag Structure: 

Unknown

This tag was intended to be used to delete a character that would not be referenced any more. The tag is not used in any movie and is not defined in the Adobe Flash documentation. 

GenerateFrame

Tag Info
Tag Number: 
47
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

This may have been something similar to a New in an action script and thus was removed later.

Tag Structure: 

Unknown

Unknown

GeneratorCommand

Tag Info
Tag Number: 
49
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

Gives some information about the tool which generated this SWF file and its version.

Tag Structure: 
struct swf_defineinfo {
	swf_tag			f_tag;		/* 31 */
	unsigned long		f_version;
	string			f_info;
};

Define some information about the tool which generated this SWF movie file.

The information seems to be formatted with names written between periods (.). The two I found are "com" (comment?) and "commands" (used when you edit the movie?).

Import

Tag Info
Tag Number: 
57
Tag Type: 
Define
Tag Flash Version: 
5
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Imports a list of definitions that are to be loaded from another movie. You can retrieve objects that were exported in the specified movie. You can have as many import as you like, though you should really only have one per referenced movie.

Tag Structure: 
struct swf_import {
	swf_tag			f_tag;		/* 57 or 71  */
	string			f_url;
	if(version >= 8) {
		unsigned char		f_version;	/* must be set to 1 */
		unsigned char		f_reserved;
	}
	unsigned short		f_count;
	swf_external		f_symbol[f_count];
};

WARNING: in a Version 8 movie you MUST use an Import2 tag instead of Import or it just will not work (Import tags are ignored in version 8 movies).

The Import tag works in conjunction with the Export tag. The Import tag gives the name of another movie and a list of external names as defined for export in that other movie. There is also a list of identifiers which represent the identifier the object(s) will have in this movie (the movie with the Import tag) and they don't need to match the source movie identifiers.

The list of identifiers given in the list of the Import tag must be unique within the entire movie. The names are only used to match the names present in the Export tag of the other movie. Thus, these can be duplicates of named sprite in this movie.

There should be only one Import per referenced movie (it would be a waste to have more). It is not clear whether a movie can Export definitions when it itself Import definitions. Also, it isn't clear what happens if such an external reference fails (I assume the corresponding objects are defined as being empty shapes).

You should at least have one external reference (i.e. f_count > 0).

The f_url parameter is a standard URL which names the object to be loaded and searched for an Export tag.

The identifiers defined in this tag must be unique within the entire movie.

Since SWF version 8, we are forced to use TagImport2 (since TagImport is ignored since that version.) It includes two extra bytes: the first one must be set to 1 and the second to 0. Macromedia termed both bytes Reserved. I put f_version in the first one so that way it makes more sense to set a 1 in there. We certainly will learn later what that bit is for.

Import2

Tag Info
Tag Number: 
71
Tag Type: 
Define
Tag Flash Version: 
8
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Imports a list of definitions from another movie. In version 8+, this tag replaces the original Import tag. You can retrieve objects which were exported in the specified movie. You can have as many import as you like, although you should really only have one per referenced movie.

Tag Structure: 

Tag Structure: 
struct swf_import {
	swf_tag			f_tag;		/* 57 or 71  */
	string			f_url;
	if(version >= 8) {
		unsigned char		f_version;	/* must be set to 1 */
		unsigned char		f_reserved;
	}
	unsigned short		f_count;
	swf_external		f_symbol[f_count];
};

WARNING: in a Version 8 movie you MUST use an Import2 tag instead of Import or it just will not work (Import tags are ignored in version 8 movies).

The Import tag works in conjunction with the Export tag. The Import tag gives the name of another movie and a list of external names as defined for export in that other movie. There is also a list of identifiers which represent the identifier the object(s) will have in this movie (the movie with the Import tag) and they don't need to match the source movie identifiers.

The list of identifiers given in the list of the Import tag must be unique within the entire movie. The names are only used to match the names present in the Export tag of the other movie. Thus, these can be duplicates of named sprite in this movie.

There should be only one Import per referenced movie (it would be a waste to have more). It is not clear whether a movie can Export definitions when it itself Import definitions. Also, it isn't clear what happens if such an external reference fails (I assume the corresponding objects are defined as being empty shapes).

You should at least have one external reference (i.e. f_count > 0).

The f_url parameter is a standard URL which names the object to be loaded and searched for an Export tag.

The identifiers defined in this tag must be unique within the entire movie.

Since SWF version 8, we are forced to use TagImport2 (since TagImport is ignored since that version.) It includes two extra bytes: the first one must be set to 1 and the second to 0. Macromedia termed both bytes Reserved. I put f_version in the first one so that way it makes more sense to set a 1 in there. We certainly will learn later what that bit is for.

JPEGTables

Tag Info
Tag Number: 
8
Tag Type: 
Define
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define the tables used to compress/decompress all the SWF 1.0 JPEG images (See also DefineBitsJPEG.)

Tag Structure: 
struct swf_jpegtables {
	swf_tag			f_tag;		/* 8 */
	unsigned char		f_encoding_tables[<variable size>];
};

The JPEGTables tag is used to define the encoding tables of the JPEG images defined using the DefineBitsJPEG tag.

There can be only one JPEGTables tag in a valid SWF file. And it should be defined before any DefineBitsJPEG tag.

The content of this tag is the JPEG encoding tables defined by the 0xFF 0xDB and 0xFF 0xC4 tags. The f_encoding_tables buffed must start with 0xFF 0xD8 (SOI) and end with 0xFF 0xD9 (EOI).

Note that the player of SWF better enforces the correctness of this tag since version 8.

Metadata

Tag Info
Tag Number: 
77
Tag Type: 
Format
Tag Flash Version: 
8
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

This tag includes XML code describing the movie. The format is RDF compliant to the XMP as defined on W3C.

Tag Structure: 
struct swf_metadata {
	swf_tag			f_tag;		/* 77 */
	string			f_metadata;
};

The Metadata tag is used to describe the SWF movie in a robot readable form. It will be used by search engines to index your Flash movies.

The f_metadata string is an XML buffer defined using the RDF definition compliant with the XMP specification. You can find more information on the W3C and other websites:

RDF Primer
RDF Specification
Dublin Core

Note that this description can describe everything, from the entire movie to each single line of code in your action scripts.

The string must be UTF-8 encoded.

NameCharacter

Tag Info
Tag Number: 
40
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

Define the name of an object (for buttons, bitmaps, sprites and sounds.)

Tag Structure: 

Unknown

Intended to name objects so one can reference them in an ActionScript. Instead, PlaceObject2 was used which is better since one object can be placed multiple times in your display list and each should have a different name. With the PlaceObject2 tag, it works that way.

PathsArePostscript

Tag Info
Tag Number: 
25
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

The shape paths are defined as in postscript?

Tag Structure: 

Unknown

Apparently there was some testing with using Postscript like instructions to render shapes. I support that is close to the time when the ActionScript language was not yet fully functional. The content of this tag is not described anywhere and is more than likely not supported in newer versions.

PlaceObject

Tag Info
Tag Number: 
4
Tag Type: 
Display
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Place the specified object in the current display list.

Tag Structure: 
struct swf_placeobject {
	swf_tag			f_tag;		/* 4 */
	unsigned short		f_objec_id_ref;
	unsigned short		f_depth;
	swf_matrix		f_matrix;
	if(f_tag_data_real_size is large enough) {1
		swf_color_transform	f_color_transform;
	}
};
  • 1. The f_color_transform is an optional field. The size of the tag data determines whether it was saved or not.

This tag will be used to specify where and how to place an object in the next frame. The PlaceObject2 and PlaceObject3 tags are much different and is presented below.

The f_depth field is used to indicate at which depth the character is inserted in the current frame. The depth defines the order in which objects are rendered. A higher number defines the objects most in the front. A smaller number indicates an object drawn further back. Although illegal, there can be any number of objects at any one depth value. However, the players may or may not properly render them. Usually the last added item at a given depth is drawn behind the previously added objects at that depth. Placing one object per depth is safer (legal) so you can be sure of the drawing order.

The f_objec_id_ref is a reference to an object previously defined with one of the Define... tags.

PlaceObject2

Tag Info
Tag Number: 
26
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Place, replace, remove an object in the current display list.

Tag Structure: 
struct swf_placeobject2 {	/* and swf_placeobject3 */
	swf_tag			f_tag;		/* 26 or 70 */
	/* NOTE: the following flags can be read as one or two bytes also */
	if(version >= 8) {
		unsigned	f_place_reserved : 5;
		unsigned	f_place_bitmap_caching : 1;
		unsigned	f_place_blend_mode : 1;
		unsigned	f_place_filters : 1;
	}
	if(version >= 5) {
		unsigned	f_place_has_actions : 1;
	}
	else {
		unsigned	f_place_reserved : 1;
	}
	unsigned		f_place_has_clipping_depth : 1;
	unsigned		f_place_has_name : 1;
	unsigned		f_place_has_morph_position : 1;
	unsigned		f_place_has_color_transform : 1;
	unsigned		f_place_has_matrix : 1;
	unsigned		f_place_has_id_ref : 1;
	unsigned		f_place_has_move : 1;
	unsigned short		f_depth;
	if(f_place_has_id_ref) {
		unsigned short		f_object_id_ref;
	}
	if(f_place_has_matrix) {
		swf_matrix		f_matrix;
	}
	if(f_place_has_color_transform) {
		swf_color_transform	f_color_transform;
	}
	if(f_place_has_morph_position) {
		unsigned short		f_morph_position;
	}
	if(f_place_has_name) {
		string			f_name;1
	}
	if(f_place_has_clipping_depth) {
		unsigned short		f_clipping_depth;
	}
	/* 3 next entries since v8.0 */
	if(f_place_filters) {
		unsigned char		f_filter_count;
		swf_any_filter		f_filter;
	}
	if(f_place_blend_mode) {
		unsigned char		f_blend_mode;
	}
	if(f_place_bitmap_caching) {
		/* WARNING: this is not defined in the Macromedia documentation
		 * it may be that it was part of the blend mode whenever the person
		 * who defined this byte was testing (I copied that from somewhere else!).
		 */
		unsigned char		f_bitmap_caching;
	}
	/* since v5.0 */
	if(f_place_has_actions) {
		unsigned short		f_reserved;
		if(version >= 6) {
			unsigned long	f_all_flags;
		}
		else {
			unsigned short	f_all_flags;
		}
		swf_event		f_event[<variable>];
		if(version >= 6) {
			unsigned long	f_end;	/* always zero */
		}
		else {
			unsigned short	f_end;	/* always zero */
		}
	}
};
  • 1. Assuming that this PlaceObject2 references a DefineSprite, this name becomes the name of this instance of the sprite. This feature enables you to place the same DefineSprite multiple times in your display list each time using a different name.

This tag will be used to specify where and how to place an object in the next frame. The PlaceObject is much different and is presented separately.

The f_depth field is used to indicate at which depth the character is inserted in the current frame. There can be only one object per depth value (thus a maximum of 65536 objects can appear on a single frame).

The f_place_has_move and f_place_has_id_ref flags are used to indicate what to do at the given depth. The following table presents what happens depending on the current value.

f_place_has_move f_place_has_id_ref Action
0 0 Crash (at least in older versions of Flash)
0 1 Place or replace a character. Really, the Replace does not work most of the time if ever. When it does not work, new characters are either totally ignored or they are added along the existing characters (under or over, who knows). So far, all my tests fail to do a valid replace.
1 0 Alter the character at the specified depth. Keep the same character. This is used to change the color transform, matrix, etc.
1 1 Remove the character at this depth. The other data is ignored and should not be defined. Same as RemoveObject2.

The f_morph_position is used in two cases.

(1) When the place object references a DefineMorphShape object. In this case, it defines a linear position between the first and second shapes (0 - draws shape 1 and 65535 - draws shape 2, any intermediate value draws a morphed shape, smaller the value the more it looks like shape 1 larger the value, the more it looks like shape 2).

(2) When the place object references a VideoFrame object. In this case, the morph position represents the frame number. This means any movie is limited to 65536 frames (the first frame is frame #0). At a regular, NTSC frame rate, it represents about 18 minutes of video. Long videos can be created using a new video stream every 18 minutes.

The f_clipping_depth parameter is used to tell the player to use the linked shape (DefineShape) or text (DefineText) as a mask for all the objects inserted in the display list from f_depth to f_clipping_depth inclusive. The mask itself isn't drawn in the screen. For instance, you could create a sprite which draws a burning fire. To place this fire in a text, insert the text with this clipping feature with a depth, say, of 7 and clipping depth of 8 and place the fire at a depth of 8 (note that to have an animation, the fire will certainly be a sprite). The fire will only appear in the text letters. Obviously this is somewhat limited since the f_clipping_depth is hard coded and not a range (Macromedia should have used depth + clip like in SSWF instead). Note that it doesn't seem to work with duplicated sprites even if these are placed at the right depth.

NOTE:

At this time I checked and I can tell that the following objects will work for clipping purposes:

and the following will not work:

The following need to be checked, I also added a comment telling whether I think it has a chance to work:

The f_blend_mode parameter is one byte which is included only when f_place_blend_mode is set to 1. The possible values are as defined in the following table. The equations use R as Result, C as the object color component, B and the background color. All components are viewed as values from 0 to 255. The result is a temporary value which is later saved in the new background before processing the next object.

Values not shown in the following table are reserved for future blending modes.

Name Value Comment Version
Normal 0 or 1 Copy the object as is.

R = C
8
Layer 2 Uses multiple objects to render (?) 8
Multiply 3 Multiply the background with the object colors.

R = B × C / 255
8
Screen 4 Multiply the inverse colors of the background and the object.

R = (255 - B) × (255 - C) / 255
8
Lighten 5 Take the largest of each component of the background and object.

R = max(B, C)
8
Darken 6 Take the smallest of each component of the background and object.

R = min(B, C)
8
Difference 7 Defines the absolute value of the difference.

R = | B - C |
8
Add 8 Add the components and clamp at 255.

R = min(B + C, 255)
8
Subtract 9 Subtract the components and clamp at 0.

R = max(B - C, 0)
8
Invert 10 Inverse the background components

R = 255 - B
8
Alpha 11 Copy the alpha channel of the object in the background. This mode requires that the parent (background) be set to mode Layer.

Ra = Ca
8
Erase 12 Copy the inverse of the alpha channel of the object in the background alpha. This mode requires that the parent (background) be set to mode Layer.

Ra = 255 - Ca
8
Overlay 13 Apply the same effect as multiply or screen depending on the background color before the operation. (Note: the comparison with 128 could be <= and the results would be same for C but not B. I currently do not know which one is picked)

R = (B < 128 ? B × C : (255 - B) × (255 - C)) / 255
8
HardLight 14 Apply the same effect as multiply or screen depending on the object color. (Note: the comparison with 128 could be <= and the results would be same for C but not B. I currently do not know which one is picked)

R = (C < 128 ? B × C : (255 - B) × (255 - C)) / 255
8

The f_bitmap_caching seems to be one byte. It is present only when the f_place_bitmap_caching is set to 1. At this time, I do not know the exact definition and it could be that it does not exist (the Macromedia reference does not include it.) I will need to test this byte to see whether it is a mistake in the Macromedia documentation or from the person who thought adding the Bitmap Caching flag was also a reason to add one byte in the structure.

PlaceObject3

Tag Info
Tag Number: 
70
Tag Type: 
Display
Tag Flash Version: 
8
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Place an object in the display list. The object can include bitmap caching information, a blend mode and a set of filters.

Tag Structure: 

Tag Structure: 
struct swf_placeobject2 {	/* and swf_placeobject3 */
	swf_tag			f_tag;		/* 26 or 70 */
	/* NOTE: the following flags can be read as one or two bytes also */
	if(version >= 8) {
		unsigned	f_place_reserved : 5;
		unsigned	f_place_bitmap_caching : 1;
		unsigned	f_place_blend_mode : 1;
		unsigned	f_place_filters : 1;
	}
	if(version >= 5) {
		unsigned	f_place_has_actions : 1;
	}
	else {
		unsigned	f_place_reserved : 1;
	}
	unsigned		f_place_has_clipping_depth : 1;
	unsigned		f_place_has_name : 1;
	unsigned		f_place_has_morph_position : 1;
	unsigned		f_place_has_color_transform : 1;
	unsigned		f_place_has_matrix : 1;
	unsigned		f_place_has_id_ref : 1;
	unsigned		f_place_has_move : 1;
	unsigned short		f_depth;
	if(f_place_has_id_ref) {
		unsigned short		f_object_id_ref;
	}
	if(f_place_has_matrix) {
		swf_matrix		f_matrix;
	}
	if(f_place_has_color_transform) {
		swf_color_transform	f_color_transform;
	}
	if(f_place_has_morph_position) {
		unsigned short		f_morph_position;
	}
	if(f_place_has_name) {
		string			f_name;1
	}
	if(f_place_has_clipping_depth) {
		unsigned short		f_clipping_depth;
	}
	/* 3 next entries since v8.0 */
	if(f_place_filters) {
		unsigned char		f_filter_count;
		swf_any_filter		f_filter;
	}
	if(f_place_blend_mode) {
		unsigned char		f_blend_mode;
	}
	if(f_place_bitmap_caching) {
		/* WARNING: this is not defined in the Macromedia documentation
		 * it may be that it was part of the blend mode whenever the person
		 * who defined this byte was testing (I copied that from somewhere else!).
		 */
		unsigned char		f_bitmap_caching;
	}
	/* since v5.0 */
	if(f_place_has_actions) {
		unsigned short		f_reserved;
		if(version >= 6) {
			unsigned long	f_all_flags;
		}
		else {
			unsigned short	f_all_flags;
		}
		swf_event		f_event[<variable>];
		if(version >= 6) {
			unsigned long	f_end;	/* always zero */
		}
		else {
			unsigned short	f_end;	/* always zero */
		}
	}
};
  • 1. Assuming that this PlaceObject2 references a DefineSprite, this name becomes the name of this instance of the sprite. This feature enables you to place the same DefineSprite multiple times in your display list each time using a different name.

This tag will be used to specify where and how to place an object in the next frame. The PlaceObject is much different and is presented separately.

The f_depth field is used to indicate at which depth the character is inserted in the current frame. There can be only one object per depth value (thus a maximum of 65536 objects can appear on a single frame).

The f_place_has_move and f_place_has_id_ref flags are used to indicate what to do at the given depth. The following table presents what happens depending on the current value.

f_place_has_move f_place_has_id_ref Action
0 0 Crash (at least in older versions of Flash)
0 1 Place or replace a character. Really, the Replace does not work most of the time if ever. When it does not work, new characters are either totally ignored or they are added along the existing characters (under or over, who knows). So far, all my tests fail to do a valid replace.
1 0 Alter the character at the specified depth. Keep the same character. This is used to change the color transform, matrix, etc.
1 1 Remove the character at this depth. The other data is ignored and should not be defined. Same as RemoveObject2.

The f_morph_position is used in two cases.

(1) When the place object references a DefineMorphShape object. In this case, it defines a linear position between the first and second shapes (0 - draws shape 1 and 65535 - draws shape 2, any intermediate value draws a morphed shape, smaller the value the more it looks like shape 1 larger the value, the more it looks like shape 2).

(2) When the place object references a VideoFrame object. In this case, the morph position represents the frame number. This means any movie is limited to 65536 frames (the first frame is frame #0). At a regular, NTSC frame rate, it represents about 18 minutes of video. Long videos can be created using a new video stream every 18 minutes.

The f_clipping_depth parameter is used to tell the player to use the linked shape (DefineShape) or text (DefineText) as a mask for all the objects inserted in the display list from f_depth to f_clipping_depth inclusive. The mask itself isn't drawn in the screen. For instance, you could create a sprite which draws a burning fire. To place this fire in a text, insert the text with this clipping feature with a depth, say, of 7 and clipping depth of 8 and place the fire at a depth of 8 (note that to have an animation, the fire will certainly be a sprite). The fire will only appear in the text letters. Obviously this is somewhat limited since the f_clipping_depth is hard coded and not a range (Macromedia should have used depth + clip like in SSWF instead). Note that it doesn't seem to work with duplicated sprites even if these are placed at the right depth.

NOTE:

At this time I checked and I can tell that the following objects will work for clipping purposes:

and the following will not work:

The following need to be checked, I also added a comment telling whether I think it has a chance to work:

The f_blend_mode parameter is one byte which is included only when f_place_blend_mode is set to 1. The possible values are as defined in the following table. The equations use R as Result, C as the object color component, B and the background color. All components are viewed as values from 0 to 255. The result is a temporary value which is later saved in the new background before processing the next object.

Values not shown in the following table are reserved for future blending modes.

Name Value Comment Version
Normal 0 or 1 Copy the object as is.

R = C
8
Layer 2 Uses multiple objects to render (?) 8
Multiply 3 Multiply the background with the object colors.

R = B × C / 255
8
Screen 4 Multiply the inverse colors of the background and the object.

R = (255 - B) × (255 - C) / 255
8
Lighten 5 Take the largest of each component of the background and object.

R = max(B, C)
8
Darken 6 Take the smallest of each component of the background and object.

R = min(B, C)
8
Difference 7 Defines the absolute value of the difference.

R = | B - C |
8
Add 8 Add the components and clamp at 255.

R = min(B + C, 255)
8
Subtract 9 Subtract the components and clamp at 0.

R = max(B - C, 0)
8
Invert 10 Inverse the background components

R = 255 - B
8
Alpha 11 Copy the alpha channel of the object in the background. This mode requires that the parent (background) be set to mode Layer.

Ra = Ca
8
Erase 12 Copy the inverse of the alpha channel of the object in the background alpha. This mode requires that the parent (background) be set to mode Layer.

Ra = 255 - Ca
8
Overlay 13 Apply the same effect as multiply or screen depending on the background color before the operation. (Note: the comparison with 128 could be <= and the results would be same for C but not B. I currently do not know which one is picked)

R = (B < 128 ? B × C : (255 - B) × (255 - C)) / 255
8
HardLight 14 Apply the same effect as multiply or screen depending on the object color. (Note: the comparison with 128 could be <= and the results would be same for C but not B. I currently do not know which one is picked)

R = (C < 128 ? B × C : (255 - B) × (255 - C)) / 255
8

The f_bitmap_caching seems to be one byte. It is present only when the f_place_bitmap_caching is set to 1. At this time, I do not know the exact definition and it could be that it does not exist (the Macromedia reference does not include it.) I will need to test this byte to see whether it is a mistake in the Macromedia documentation or from the person who thought adding the Bitmap Caching flag was also a reason to add one byte in the structure.

ProductInfo

Tag Info
Tag Number: 
41
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

This tag defines information about the product used to generate the animation. The product identifier should be unique among all the products. The info includes a product identifier, a product edition, a major and minor version, a build number and the date of compilation. All of this information is all about the generator, not the output movie.

Tag Structure: 
struct swf_metadata {
	swf_tag			f_tag;		/* 41 */
	long			f_product_id;
	long			f_edition;
	unsigned char		f_major_version;
	unsigned char		f_minor_version;
	long long		f_build_number;
	long long		f_compilation_date;
};

The ProductInfo tag stores information about the tool used to generate the Flash animation. This is ignored by flash players (unless it knows of problems in the generators...)

The f_product_id is expected to be a unique identifier for all the products which can possibly generate an SWF output file.

The f_edition represents an edition of the generator. For instance, you may have a free version, and three commercial versions (Standard, Pro and Deluxe) which all should have a different edition number. Yet, the product is the same.

The f_major_version and f_minor_version are used to define the generator version used to create the SWF animation. Note that these numbers are limited to a value between 0 and 255.

The f_build_number is usually a MS-Windows build number. This does not really apply to Unix versions. Under Unix, one can use this number to extend the version to additional digits (i.e. SSWF saves 1.8.1 in the build number.)

The f_compilation_date represents the date and time when the generator was compiled (not the time when the output movie is generated!)

Protect

Tag Info
Tag Number: 
24
Tag Type: 
Define
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Disable edition capabilities of the given SWF file. Though this doesn't need to be enforced by an SWF editor, it marks the file as being copyrighted in a way.

WARNING: this tag is only valid in Flash V2.x, V3.x, and V4.x, use the EnableDebugger instead in V5.x and EnableDebugger2 in V6.x and newer movies.

Tag Structure: 
struct swf_protect {
	swf_tag			f_tag;		/* 24, 58 or 64  */
	if(version >= 5) {
		if(tag == ProtectDebug2) {
			unsigned short	f_reserved;1
		}
		/* the password is optional when tag == Protect */
		string		f_md5_password;
	}
};
  • 1. f_reserved must be set to zero.

The protection tag is totally useless. The SWF format is an open format, otherwise how would you have so many players and tools to work with SWF movies? Thus, you can pretend to protect your movies, but anyone with a simple binary editor can transform the tag and make it another which has no such effect. Also, swf_dump and some other tools (such as flasm) can read your movie anyway.

For the sake of defining what you have in each tag, there are the protection tags fully described.

According to Macromedia, you can find some free implementation of the MD5 algorithm by Poul-Henning Kamp in FreeBSD in the file src/lib/libcrypt/crypt-md5.c. For your convenience, there is an implementation of that MD5 sum in the SSWF library.

IMPORTANT

Version 2, 3, 4 must use Protect.

Version 5 must use EnableDebugger.

Version 6 and over must use EnableDebugger2.

RemoveObject

Tag Info
Tag Number: 
5
Tag Type: 
Display
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Remove the specified object at the specified depth.

Tag Structure: 
struct swf_removeobject {
	swf_tag			f_tag;		/* 5 or 28 */
	if(f_tag == RemoveObject) {
		unsigned short		f_object_id_ref;
	}
	unsigned short		f_depth;
};

Remove the specified object from the display list. If the same object was placed multiple times at the specified depth1 only the last copy is removed. When only a depth is specified, the last object placed at that depth is removed from the list. Note that since version 3 it is possible to use the PlaceObject2 in order to replace an object at a given depth without having to remove it first.

  • 1. It is illegal, yet possible, to place more than one object at the same depth.

RemoveObject2

Tag Info
Tag Number: 
28
Tag Type: 
Display
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Remove the object at the specified level. This tag should be used in movies version 3 and over since it compressed better than the standard RemoveObject tag. Note that a PlaceObject2 can also be used for this task.

Tag Structure: 

Tag Structure: 
struct swf_removeobject {
	swf_tag			f_tag;		/* 5 or 28 */
	if(f_tag == RemoveObject) {
		unsigned short		f_object_id_ref;
	}
	unsigned short		f_depth;
};

Remove the specified object from the display list. If the same object was placed multiple times at the specified depth1 only the last copy is removed. When only a depth is specified, the last object placed at that depth is removed from the list. Note that since version 3 it is possible to use the PlaceObject2 in order to replace an object at a given depth without having to remove it first.

  • 1. It is illegal, yet possible, to place more than one object at the same depth.

ScriptLimits

Tag Info
Tag Number: 
65
Tag Type: 
Define
Tag Flash Version: 
7
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Change limits used to ensure scripts do not use more resources than what you choose. In version 7, it supports a maximum recursive depth and a maximum amount of time scripts can be run for in seconds.

Tag Structure: 
struct swf_scriptlimits {
	swf_tag			f_tag;		/* 65 */
	unsigned short		f_max_recursion_depth;
	unsigned short		f_timeout_seconds;
};

This tag is used to change the default limits of script execution.

The maximum recursion depth is 256 by default. Any value, except zero (0) is valid.

The f_timeout_seconds parameter specifies the number of seconds before the players opens a dialog box saying that the SWF animation is stuck.

This can be very useful if you have some heavy initialization which takes more resources than a few seconds (~15 seconds by default), and/or has a lot of recursivity (or just calls? to be tested...). You can then set large limits for the initialization to run fine, and then put some much lower limits afterward so as to ensure that the other scripts don't use too much resources.

SetBackgroundColor

Tag Info
Tag Number: 
9
Tag Type: 
Display
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Change the background color. Defaults to white if unspecified.

Tag Structure: 
struct swf_setbackgroundcolor {
	swf_tag			f_tag;		/* 9 */
	swf_rgb			f_rgb;
};

This tag is used to specify the background color. It should always be included at the start of every .swf file (after the FileAttributes and Protect tags). Only an RGB color can be used (i.e. there is no alpha channel for that color, whatever the SWF version.)

To create a Flash animation that's transparent (so we can see the website gradient, for example) you use the wmode parameter in the HTML tag with the value "transparent", in which case the background color will be ignored and replaced by a fully transparent background. For example:

<embed width="440" height="241" type="application/x-shockwave-flash"
       pluginspage="http://www.macromedia.com/go/getflashplayer"
       src="/sites/linux.m2osw.com/files/images/indoor-comfort.swf"
       play="true" loop="true" menu="true" wmode="transparent"></embed>

There is no parameter you can set inside the Flash animation itself to make it transparent in your browser.

 

SetTabIndex

Tag Info
Tag Number: 
66
Tag Type: 
Define
Tag Flash Version: 
7
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Define the order index so the player knows where to go next when the Tab key is pressed by the user.

Tag Structure: 
struct swf_settabindex {
	swf_tag			f_tag;		/* 66 */
	unsigned short		f_depth;
	unsigned short		f_tab_index;
};

This tag defines the tab index of any text object (static and dynamic text objects.)

The depth references the object which is assigned the tab index. The tab index defines the order in which objects are sorted to know where to go next when the tab key is pressed.

ShowFrame

Tag Info
Tag Number: 
1
Tag Type: 
Display
Tag Flash Version: 
1
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Display the current display list and pauses for 1 frame as defined in the file header.

Tag Structure: 
struct swf_showframe {
	swf_tag			f_tag;		/* 1 */
};

This empty tag signals to the player to display the current frame. The player will then fall asleep until it is time to draw the next frame (well... actually, it should prepare the next frame and then sleep if necessary before showing the next frame.)

SoundStreamBlock

Tag Info
Tag Number: 
19
Tag Type: 
Define
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

A block of sound data (i.e. audio samples.) The size of this block of data is defined in the previous SoundStreamHead tag. It is used to download sound samples on a per frame basis instead of all at once.

Tag Structure: 
struct swf_soundstreamblock {
	swf_long_tag		f_tag;		/* 19 */
	unsigned char		f_sound_data[variable size];
};

The SoundStreamBlock tag defines the data of a sound effect previously defined with a SoundStreamHead or a SoundStreamHead2 tag.

WARNING: This tag requires you to save the swf_tag structure in long format whatever the size of the data (i.e. f_tag_and_size & 0x3F == 0x3F always true even if the size is 62 or less.)

The data depends on the SoundStreamHead[2] definition and is variable in size. Please, see the DefineSound tag for more information about sound data.

SoundStreamHead

Tag Info
Tag Number: 
18
Tag Type: 
Define
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Declare a sound effect which will be interleaved with a movie data so as to be loaded over a network connection while being played.

Tag Structure: 
struct swf_soundstreamhead {
	swf_tag			f_tag;		/* 18 or 45 */
	unsigned		f_compression : 4;
	unsigned		f_sound_rate : 2;
	unsigned		f_sound_size : 1;
	unsigned		f_sound_stereo : 1;
	unsigned		f_reserved : 4;
	unsigned		f_playback_rate : 2;
	unsigned		f_playback_size : 1;
	unsigned		f_playback_stereo : 1;
	unsigned short		f_sample_size;
	if(f_compression == 2) {
		signed short	f_latency_seek;
	}
};

The SoundStreamHead[2] tags define a sound effect which is to be loaded with a set of SoundStreamBlock tags. It defines the sound once and for all.

Streaming sound has a strong side effect when playing a movie: it will force a synchronization between the images and the audio. Thus some images may be dropped if the drawing isn't fast enough.

Streaming sound effects should be either used in the main movie or in a sprite which needs a sound track properly synchronized to the sprite animation. Otherwise, it is much better to use the DefineSound and StartSound tags.

It seems (though it isn't documented) that using a SoundStreamHead tag by itself (without any sound blocks) is taken as a hint of how to play all the other sounds in an animation (see the f_playback_rate)

Important note: there can be only one streaming sound per movie clip including the main movie. If you need multiple sound effects or music to be played back, these will have to be merged at the time you create the movie in a single sound which will then be played back as a single sound track.

Some of the fields in the SoundStreamHead tag can't have all the possible values when defined in an older version of SWF. What follows describes each field in more details.

The f_playback_rate and f_sound_rate define the rate at which the data should be played and the exact rate of the data found in the SWF file.

	rate = 5512.5 * 2 ** f_playback_rate
	rate = 5512.5 * 2 ** f_sound_rate

The f_playback_size and f_sound_size define the number of bits found in the data (0 for 8 bits and 1 for 16 bits.) Note that with a SoundStreamHead tag (18) only 16 bits data are allowed (both are always set to 1). If the compression mode isn't Raw or Uncompressed then the f_sound_size must be set to 1.

The f_playback_stereo and f_sound_stereo define whether the sound should be played on both speakers and whether the data includes both channels.

The f_compression entry defines the compression mode. The list of sound compression modes can be found with the DefineSound tag. Note that with a SoundStreamHead tag (18) only the ADPCM compression is accepted. All the compression modes are accepted in a SoundStreamHead2 tag (45).

The f_sample_size represents the average number of samples per frame. It is used to ensure a proper synchronization. Note that there can be more (and even less in MP3) samples within a given frame.

The f_latency_seek is usually zero. It exists only when the MP3 compression mode is used. It defines the number of samples to skip at the beginning of the very first frame (I'm not totally sure what this is to tell you the truth... I'll tell you more once I know more).

SoundStreamHead2

Tag Info
Tag Number: 
45
Tag Type: 
Define
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Declare a sound effect which will be interleaved with a movie data so as to be loaded over a network connection while being played.

Tag Structure: 

Tag Structure: 
struct swf_soundstreamhead {
	swf_tag			f_tag;		/* 18 or 45 */
	unsigned		f_compression : 4;
	unsigned		f_sound_rate : 2;
	unsigned		f_sound_size : 1;
	unsigned		f_sound_stereo : 1;
	unsigned		f_reserved : 4;
	unsigned		f_playback_rate : 2;
	unsigned		f_playback_size : 1;
	unsigned		f_playback_stereo : 1;
	unsigned short		f_sample_size;
	if(f_compression == 2) {
		signed short	f_latency_seek;
	}
};

The SoundStreamHead[2] tags define a sound effect which is to be loaded with a set of SoundStreamBlock tags. It defines the sound once and for all.

Streaming sound has a strong side effect when playing a movie: it will force a synchronization between the images and the audio. Thus some images may be dropped if the drawing isn't fast enough.

Streaming sound effects should be either used in the main movie or in a sprite which needs a sound track properly synchronized to the sprite animation. Otherwise, it is much better to use the DefineSound and StartSound tags.

It seems (though it isn't documented) that using a SoundStreamHead tag by itself (without any sound blocks) is taken as a hint of how to play all the other sounds in an animation (see the f_playback_rate)

Important note: there can be only one streaming sound per movie clip including the main movie. If you need multiple sound effects or music to be played back, these will have to be merged at the time you create the movie in a single sound which will then be played back as a single sound track.

Some of the fields in the SoundStreamHead tag can't have all the possible values when defined in an older version of SWF. What follows describes each field in more details.

The f_playback_rate and f_sound_rate define the rate at which the data should be played and the exact rate of the data found in the SWF file.

	rate = 5512.5 * 2 ** f_playback_rate
	rate = 5512.5 * 2 ** f_sound_rate

The f_playback_size and f_sound_size define the number of bits found in the data (0 for 8 bits and 1 for 16 bits.) Note that with a SoundStreamHead tag (18) only 16 bits data are allowed (both are always set to 1). If the compression mode isn't Raw or Uncompressed then the f_sound_size must be set to 1.

The f_playback_stereo and f_sound_stereo define whether the sound should be played on both speakers and whether the data includes both channels.

The f_compression entry defines the compression mode. The list of sound compression modes can be found with the DefineSound tag. Note that with a SoundStreamHead tag (18) only the ADPCM compression is accepted. All the compression modes are accepted in a SoundStreamHead2 tag (45).

The f_sample_size represents the average number of samples per frame. It is used to ensure a proper synchronization. Note that there can be more (and even less in MP3) samples within a given frame.

The f_latency_seek is usually zero. It exists only when the MP3 compression mode is used. It defines the number of samples to skip at the beginning of the very first frame (I'm not totally sure what this is to tell you the truth... I'll tell you more once I know more).

StartSound

Tag Info
Tag Number: 
15
Tag Type: 
Display
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Start playing the referenced sound on the next ShowFrame.

Tag Structure: 
struct swf_startsound {
	swf_tag			f_tag;		/* 15 */
	swf_sound_info		f_sound_info;
};

The StartSound tag is used to playback a sound defined with the DefineSound tag.

StopSound

Tag Info
Tag Number: 
15
Tag Type: 
Display
Tag Flash Version: 
2
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

Start playing the referenced sound on the next ShowFrame.

Tag Structure: 

Unknown

Apparently, the authors first thought that a StopSound tag would be useful. Since the StartSound offers that functionality, however, it was removed.

SymbolClass

Tag Info
Tag Number: 
76
Tag Type: 
Action
Tag Flash Version: 
9
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Instantiate objects from a set of classes.

Tag Structure: 
struct swf_symbolclass {
	swf_tag			f_tag;		/* 76 */
	unsigned short		f_symbol_count;
	struct {
		unsigned short		f_symbol_id;
		string			f_symbol_name;
	} f_symbol_references[f_symbol_count];
};

The SymbolClass tag is used to instantiate objects from action script version 3 definitions (see DoABCDefine.) You can instantiate each object only once with this technique.

The f_symbol_id references an ActionScript version 3 object (DoABC) and the f_symbol_name references the class to instantiate.

When f_symbol_id is set to zero, this tag becomes a special case and uses the f_symbol_name as the name of the top level class (root? TBD.)

SyncFrame

Tag Info
Tag Number: 
29
Tag Type: 
Display
Tag Flash Version: 
3
Unknown SWF Tag: 
This tag is not known (not defined by the Flash documentation by Adobe)
Brief Description: 

Tag used to synchronize the animation with the hardware.

Tag Structure: 

Unknown

Apparently, Macromedia thought that synchronizing their animation with, probably, the VLB would be a good idea. Yet they dropped it and never released that out. It is probably not useful for animations (visual) to be properly synchronize when there is not audio. If you do have audio, you should synchronize the animation to the audio and drop visual frames as required to keep up with the audio.

VideoFrame

Tag Info
Tag Number: 
61
Tag Type: 
Define
Tag Flash Version: 
6
Unknown SWF Tag: 
This tag is defined by the Flash documentation by Adobe
Brief Description: 

Show the specified video frame of a movie.

Tag Structure: 
struct swf_startsound {
	swf_tag			f_tag;		/* 61 */
	unsigned short		f_video_id_ref;
	unsigned short		f_frame;
	unsigned char		f_video_data[variable size];
};

The VideoFrame tag is used to render one frame. It includes the data of exactly one video frame to be drawn on the screen.

The f_object_id_ref parameter is a reference to a DefineVideoStream.

The f_frame parameter defines which frame needs to be rendered. Note, however, that is not enough to display the video frame in the output. For that purpose you also need to use a PlaceObject2 or PlaceObject3 with their morph parameter (f_morph_position) set to the same frame number. This method limits the videos to 65536 frames (about 18 minutes of video). Longer videos can be created using multiple video stream blocks.

The f_video_data content depends on the codec defined in the DefineVideoStream tag. Once I really know what that data is, I will update this documentation. Note that the Sorenson H.263 encoding is actually a subset of MPEG-2.