SWF文件格式说明书--SWF文件结构

类别:软件工程 点击:0 评论:0 推荐:

SWF File Structure

SWF文件结构

Following the header is a series of tagged data blocks. All tags share a common format, so any

program parsing a SWF file can skip over blocks it does not understand. Data inside the block can

point to offsets within the block, but can never point to an offset in another block. This enables

tags to be removed, inserted, or modified by tools that process a SWF file.

在文件头后面的是一些标签化的数据块。所有的标签都是用一种通用格式。所以任何程序在解析一个SWF文件时,都可以跳过那些还不明确的块。在每个块中的数据可以指向这个块中的偏移量,但绝不能指向另外一个块的偏移量。这样,在用工具处理SWF文件的时候就任意可以删除、插入和修改(而SWF文件不会被破坏)。

 

 

Tag Format

标签格式

Each tag begins with a tag type and a length. There are two tag header formats, short and long.

Short tag headers are used for tags with 62 bytes of data or less. Long tag headers can be used for

any tag size up to 4GB, far larger than is presently practical.

每个标签都以标签类型和长度开头。标签头格式有两种,短型和长型。短型标签头用在数据不超过62字节的标签;长型标签头则可用在比实际用到的大小大得多的4GB之内的任何标签中。

 

标签头(短型)

字段

类型

备注

TagCodeAndLength(标签类型和长度)

16位

高10位:标签类型

低6位:标签长度

 

Note: The TagCodeAndLength field is a two-byte word, not a bitfield of 10 bits followed by a bitfield

of 6 bits. The little-endian byte ordering of SWF makes these two layouts different.

The length specified in the TagCodeAndLength field does not include the RECORDHEADER

that starts a tag.

TagCodeAndLength字段是一个占两字节的字,而不是一个10位二进制字段后面跟着6位二进制字段。

If the tag is 63 bytes or longer, it is stored in a long tag header. The long tag header consists of a

short tag header with a length of 0x3f, followed by a 32-bit length.

假如标签是63字节或者更长,它具有长型标签头。长型标签头就好像一个以0x3f开头的短型标签头,后面跟着一个32位长度。

标签头(长型)

字段

类型

备注

TagCodeAndLength(标签类型和长度)

16位

标签类型和标签长度(这儿的标签长度不是真实的)合起来是0x3f,包装起来像短型标签头

长度

32位

标签长度

 

Definition and Control Tags

定义型标签和控制型标签

There are two categories of tags in SWF:

Definition Tags These tags define the content of the SWF movie – the shapes, text, bitmaps,

sounds, and so on. Each definition tag assigns a unique ID called a character ID to the content it

defines. Flash Player then stores the character in a repository called the dictionary. Definition

tags, by themselves, do not cause anything to be rendered.

Control Tags These tags create and manipulate rendered instances of characters in the

dictionary, and control the flow of the movie.

SWF有两种类类型的标签:

定义型标签:这类标签定义SWF影片的内容,如各种形状,文字,位图,声音等等。每个定义型标签在内容被定义都分配了一个唯一的标识号给它,这叫做角色标识(character ID)。.flash播放器则把这些角色放到一个存储空间里面,这个存储空间我们一般叫它字典。用定义型tag是不会绘制任何图形的,不会产生任何动画的。

控制型标签:这类标签用来产生和操作字典中的角色实例的渲染,并且控制影片的流程。

Tag Ordering in SWF

SWF标签的排序

Generally speaking, tags in a SWF can occur in any order. However, there are a few rules that

must be observed:

1 A tag should only depend on tags that come before it. A tag should never depend on a tag that

comes later in the file.

2 A definition tag that defines a character must occur before any control tag that refers to that

character.

3 Streaming sound tags must be in order. Out-of-order streaming sound tags will result in the

sound being played out of order.

4 The End tag is always the last tag in the SWF file.

总的来说,标签可以出现任何情况的排序方法,但也不是随便乱排, 它遵循一些规则:

1.一个标签只能依靠在它之前的标签,不能依靠在它之后的标签.

2.一个定义了角色的定义型标签必须在引用这个角色的控制型标签之前。

3.流媒体标签必须有顺序,没有顺序的流媒体播放起来也是没有顺序的

4.结束标签(tag)应该在SWF文件的最后。

 

(本文谢绝转载,欢迎指正错误,^_^)

本文地址:http://com.8s8s.com/it/it35057.htm