翻译 2012年03月23日 18:24:58


Chapter 1 Basic Data Types

Coordinates and twips

The SWF file format stores all x-y coordinates as integers, usually in a unit of measurement

called a twip. In the SWF format, a twip is 1/20th of a logical pixel. A logical pixel is the same

as a screen pixel when the file is played at 100%that is, without scaling.






Integer types and byte order

The SWF file format uses 8-bit, 16-bit, 32-bit, 64-bit, signed, and unsigned integer types. All

integer values are stored in the SWF file by using little-endian byte order: the least significant

byte is stored first, and the most significant byte is stored last, in the same way as the Intel x86

architecture. The bit order within bytes in the SWF file format is big-endian: the most

significant bit is stored first, and the least significant bit is stored last.




方式存储的值都是使用little-endian 字节序,即低字节存储在低位,高字节存储在高位。Intel x86架构


MATRIX record

The MATRIX record represents a standard 2x3 transformation matrix of the sort commonly

used in 2D graphics. It is used to describe the scale, rotation, and translation of a graphic

object. The MATRIX record must be byte aligned.

MATRIX record表示的是标准的2×3排序变换矩阵,通常应用于2D,用来完成缩放,旋转及图形图像变换

MATRIX record必须是字节对齐的。







NScaleBits If HasScale = 1

UB[5] Bits in each scale value field

NScaleBits If HasScale = 1


If HasScale = 1, FB[NScaleBits] x scale value

ScaleX If HasScale = 1


If HasScale = 1, FB[NScaleBits] y scale value

ScaleY If HasScale = 1



Has rotate and skew values if equal

to 1


If HasRotate = 1,UB[5] Bits in each rotate value field

NRotateBits If HasRotate = 1


If HasRotate = 1,


First rotate and skew value


If HasRotate = 1,


Second rotate and skew value



Bits in each translate value field



x translate value in twips



y translate value in twips


Chapter 2 SWF Structure Summary


The SWF header+SWF file structure


SWF File Header

Field             Type    Comment                                            Bytes

Signature         UI8                    Signature byte:                                        1 

                                                “F” indicates uncompressed

                                                “C” indicates compressed (SWF 6 and later only)

Signature         UI8                    Signature byte always “W”                               1

Signature         UI8                    Signature byte always “S”

Version             UI8                    Single byte file version (for example, 0x06 for SWF 6)          1 

FileLength       UI32        Length of entire file in bytes                              4 

FrameSize    RECT    Frame size in twips                                     由表示最大数所需要位来决定



FrameRate      UI16        Frame delay in 8.8 fixed number of frames per second         2

FrameCount   UI16        Total number of frames in file                             2


SWF file structure

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

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

The FileAttributes tag is only required for SWF 8 and later.


|Header | FileAttributes tag | Tag | Tag | Tag | End tag


Tag format

Each tag begins with a tag type and a length. The tag-header formats can be either short or

long. Short tag headers are used for tags with 62 bytes of data or less. Long tag headers, with a

signed 32-bit length field, can be used for any tag size up to 2GB, far larger than is presently


每一个tag都是以tag type+长度方式开始的,tag-header格式可以是 short long 类型。Short

Tag headers 用来表示长度小于等于62字节的tag.Long tag headers是一个有符号的32-bit字段,








Upper 10 bits: tag type

Lower 6 bits: tag length

The length specified in the TagCodeAndLength field does not include the

RECORDHEADER that starts a tag.


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.

如果tag63字节或更长,它以long tag header方式来存储,log tag header由一个shrot tag header+0x3f+32-bit length来组成。







Tag type and length of 0x3F

Packed together as in short header



Length of tag



Definition and control tags

The two categories of tags in a SWF file are as follows:

"Definition tags" And "Control tags"


Definition tags -- define the content of the SWF file—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

Definition tags -- 定义SWF文件的内容--形状,文本,位图,声音等等,每一个 definition tag被分配一个唯一

                              ID好来表明一个已定义的内容,之后Flash Player将其存放在一个叫做“字典”的容器中,

                              Definition tag其自身不会被渲染。


Control tags -- create and manipulate rendered instances of characters in the dictionary, and

                       control the flow of the file.

Control tags -- 创建并操作字典中已渲染的角色实例,并控制文件数据流。


Tag ordering in SWF filesSWF文件中tag规则)

Generally speaking, tags in a SWF can occur in any order. However, you must observe the

following rules:

The FileAttributes tag must be the first tag in the SWF file for SWF 8 and later.

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.

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

that character.

   一个定义了角色的definition tag必须出现在任何与该角色相关control tag之前。

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

sound being played out of order.


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


The dictionary

The dictionary is a repository of characters that are defined, and are available for control tags

to use. The process of building and using the dictionary is as follows:

字典是所有被定义角色容器,为control tags所用,建立及使用字典步骤如下:

1. The definition tag defines some content, such as a shape, font, bitmap, or sound.

2. The definition tag assigns a unique CharacterId to the content.

3. The content is saved in the dictionary under the CharacterId.

4. A control tag uses the CharacterId to retrieve the content from the dictionary, and performs

some action on the content, such as displaying a shape, or playing a sound.


Every definition tag must specify a unique ID. Duplicate IDs are not allowed. Typically, the

first CharacterId is 1, the second CharacterId is 2, and so on. The number zero (0) is special

and is considered a null character.

每一个定义的 definition tag 必须制定一个唯一的ID, 负责IDs 是不允许的,通常,第一个角色ID1,其次为2,以此类推。



Control tags are not the only tags that reference the dictionary. Definition tags can use

characters from the dictionary to define more complex characters. For example, the

DefineButton and DefineSprite tags refer to other characters to define their contents. The

DefineText tag can refer to font characters to select different fonts for the text.

不仅仅Control tag能引用字典,definition tags也可以从字典中使用角色来定义更复杂的角色。例如:...


Processing a SWF file(SWF文件的处理)

Flash Player processes all of the tags in a SWF file until a ShowFrame tag is encountered. At

this point, the display list is copied to the screen and Flash Player is idle until it is time to

process the next frame. The contents of the first frame are the cumulative effect of performing

all of the control tag operations before the first ShowFrame tag. The contents of the second

frame are the cumulative effect of performing all of the control tag operations from the

beginning of the file to the second ShowFrame tag, and so on.

Flash Player在遇到 ShowFrame tag之前会处理所有的control tag,正因为如此,显示列表中的信息会被拷贝到屏幕上同时

Flash Player处于闲置状态,直到遇到下一个ShowFrame tag出现。每个ShowFrame tag中取出的control tag在显示的时候




A SWF file is made up of a header, followed by a number of tags. The two types of tags are

definition tags and control tags. Definition tags define the objects known as characters,

which are stored in the dictionary. Control tags manipulate characters, and control the flow

of the file.


一个SWF文件由 header+ much more tags 组成,tags有两种类型:definition tags control tags,

Definition tags定义角色对象,并存储在字典中,Control tags操作角色,并且控制文件数据流。


Chapter 3 The Display List(第三章,显示列表)

Displaying a frame of a SWF file is a three-stage process:

1. Objects are defined with definition tags such as DefineShape, DefineSprite, and so on.

Each object is given a unique ID called a character, and is stored in a repository called the


2. Selected characters are copied from the dictionary and placed on the display list, which is

the list of the characters that will be displayed in the next frame.

3. Once complete, the contents of the display list are rendered to the screen with ShowFrame.

显示一个swf 文件的一帧数据需要经历三个步骤:

1:用definition tags(诸如defineShape, DefineSprite)等对对象进行定义,每一个对象分配一个唯一的ID标识一个角色并存储在字典中




A depth value is assigned to each character on the display list. The depth determines the

stacking order of the character. Characters with lower depth values are displayed underneath

characters with higher depth values. A character with a depth value of 1 is displayed at the

bottom of the stack. A character can appear more than once in the display list, but at different

depths. Only one character can be at any given depth.

In SWF 1 and 2, the display list was a flat list of the objects that are present on the screen at

any given time. In SWF 3 and later versions, the display list is a hierarchical list where an

element on the display can have a list of child elements. For more information, see


depth 值被分配给显示列表中的每个角色,这个 depth 值决定角色的栈顺序,角色的depth值越小,出现的就越晚。




The following six tags are used to control the display list:

PlaceObject Adds a character to the display list.

PlaceObject2 & PlaceObject3 Adds a character to the display list, or modifies the

character at the specified depth.

RemoveObject Removes the specified character from the display list.

RemoveObject2 Removes the character at the specified depth.

ShowFrame Renders the contents of the display list to the display.


         The older tags, PlaceObject and RemoveObject, are rarely used in SWF 3 and

         later versions.


Clipping layers[裁剪层]

Flash Player supports a special kind of object in the display list called a clipping layer. A

character placed as a clipping layer is not displayed; rather it clips (or masks) the characters

placed above it. The ClipDepth field in PlaceObject2 specifies the top-most depth that the

clipping layer masks.

For example, if a shape was placed at depth 1 with a ClipDepth of 4, all depths above 1, up to

and including depth 4, are masked by the shape placed at depth 1. Characters placed at depths

above 4 are not masked.

Flash Player在显示列表中提供了一种特殊的对象类型叫裁剪层,一个角色放置在裁剪层中是不会被显示的,而是裁剪



Using the display list[显示列表的使用]

The following procedure creates and displays an animation:


1. Define each character with a definition tag.

Each character is given a unique character ID, and added to the dictionary.

为每一个角色分配一个definition tag,每一个角色分配一个唯一ID,并放置在字典中

2. Add each character to the display list with a PlaceObject2 tag. Each PlaceObject2 tag

specifies the character to be displayed, plus the following attributes:

A depth value, which controls the stacking order of the character being placed. Characters

with lower depth values appear to be underneath characters with higher depth values. A

depth value of 1 means the character is displayed at the bottom of the stack. Only one

character can be at any given depth.

A transformation matrix, which determines the position, scale, factor, and angle of

rotation of the character being placed. The same character can be placed more than once

(at different depths) with a different transformation matrix.


An optional color transform, which specifies the color effect applied to the character

being placed. Color effects include transparency and color shifts.

An optional name string, which identifies the character being placed for SetTarget

actions. SetTarget is used to perform actions inside sprite objects.

An optional ClipDepth value, which specifies the top-most depth that will be masked by

the character being placed.

An optional ratio value, which controls how a morph character is displayed when placed.

A ratio of zero displays the character at the start of the morph. A ratio of 65535 displays

the character at the end of the morph.

3. Use a ShowFrame tag to render the contents of the display list to the screen.

4. Use a PlaceObject2 tag to modify each character on the display List.

Each PlaceObject2 assigns a new transformation matrix to the character at a given depth.

The character ID is not specified because each depth can have only one character.

使用PlaceObject2 tag来修改显示列表中的每一个角色



5. Use a ShowFrame tag to display the characters in their new positions.

Repeat steps 4 and 5 for each frame of the animation.

6. Use a RemoveObject2 tag to Remove each character from the display list.

Only the depth value is required to identify the character being removed.


Display list tags

Display list tags are used to add character and character attributes to a display list.



The PlaceObject2 tag extends the functionality of the PlaceObject tag. The PlaceObject2 tag

can both add a character to the display list, and modify the attributes of a character that is

already on the display list. The PlaceObject2 tag changed slightly from SWF 4 to SWF 5. In

SWF 5, clip actions were added.

The tag begins with a group of flags that indicate which fields are present in the tag. The

optional fields are CharacterId, Matrix, ColorTransform, Ratio, ClipDepth, Name, and

ClipActions. The Depth field is the only field that is always required.

The depth value determines the stacking order of the character. Characters with lower depth

values are displayed underneath characters with higher depth values. A depth value of 1 means

the character is displayed at the bottom of the stack. Any given depth can have only one

character. This means a character that is already on the display list can be identified by its

depth alone (that is, a CharacterId is not required).

The PlaceFlagMove and PlaceFlagHasCharacter tags indicate whether a new character is

being added to the display list, or a character already on the display list is being modified. The

meaning of the flags is as follows:

PlaceFlagMove = 0 and PlaceFlagHasCharacter = 1

A new character (with ID of CharacterId) is placed on the display list at the specified

depth. Other fields set the attributes of this new character.

PlaceFlagMove = 1 and PlaceFlagHasCharacter = 0

PlaceFlagMove = 1 and PlaceFlagHasCharacter = 1

The character at the specified Depth is removed, and a new character (with ID of

CharacterId) is placed at that depth. Other fields set the attributes of this new character.

For example, a character that is moved over a series of frames has PlaceFlagHasCharacter set

in the first frame, and PlaceFlagMove set in subsequent frames. The first frame places the new

character at the desired depth, and sets the initial transformation matrix. Subsequent frames

replace the transformation matrix of the character at the desired depth.

The optional fields in PlaceObject2 have the following meaning:

The CharacterId field specifies the character to be added to the display list. CharacterId is

used only when a new character is being added. If a character that is already on the display

list is being modified, the CharacterId field is absent.

The Matrix field specifies the position, scale and rotation of the character being added

or modified.

The ColorTransform field specifies the color effect applied to the character being added

or modified.

The Ratio field specifies a morph ratio for the character being added or modified. This

field applies only to characters defined with DefineMorphShape, and controls how far the

morph has progressed. A ratio of zero displays the character at the start of the morph. A

ratio of 65535 displays the character at the end of the morph. For values between zero and

65535 Flash Player interpolates between the start and end shapes, and displays an inbetween


The ClipDepth field specifies the top-most depth that will be masked by the character

being added. A ClipDepth of zero indicates that this is not a clipping character.

The Name field specifies a name for the character being added or modified. This field is

typically used with sprite characters, and is used to identify the sprite for SetTarget

actions. It allows the main file (or other sprites) to perform actions inside the sprite (see

Sprites and Movie Clips on page 231).

The ClipActions field, which is valid only for placing sprite characters, defines one or

more event handlers to be invoked when certain events occur.


Chapter 4  Control  tags

Control tags manage some overall aspects of files, frames, and playback in SWF files.

Control tags是针对SWF文件帧,回放等宏观,全局的一些方面进行管理

















(see note following



If 1, the SWF file uses GPU compositing

features when drawing graphics, where such

acceleration is available.

If 0, the SWF file will not use hardware

accelerated graphics facilities.

Minimum file version is 10.






Chapter 5 Actions

Actions are an essential part of an interactive SWF file. Actions allow a file to react to events

such as mouse movements or mouse clicks. The SWF 3 action model and earlier supports a

simple action model. The SWF 4 action model supports a greatly enhanced action model that

includes an expression evaluator, variables, and conditional branching and looping. The

SWF 5 action model adds a JavaScript-style object model, data types, and functions.

行为对于相与SWF文件进行互动是必须的一部分,行为允许SWF文件对事件作出反应(如鼠标移动或鼠标点击事件)SWF 3 action model以及早期版本支持一些简单的行为模型,SWF 4 action model支持的行为模型有了很大增强,包括表达式计算,变量,条件分支及循环,SWF 5 action model 还添加了java script风格的脚本,数据类型及函数


SWF 3 action model

The SWF 3 action model consists of eleven instructions for Flash Player:






Start playing at the current frame



Stop playing at the current frame



Go to the next frame



Go to the previous frame



Go to the specified frame



Go to the frame with the specified label



Wait for the specified frame



Get the specified URL



Stop all sounds playing



Toggle the display between high and low




Change the context of subsequent actions to a

named object


An action (or list of actions) can be triggered by a button state transition, or by SWF 3

actions. The action is not executed immediately, but is added to a list of actions to be

processed. The list is executed on a ShowFrame tag, or after the button state has changed. An

action can cause other actions to be triggered, in which case, the action is added to the list of

actions to be processed. Actions are processed until the action list is empty.

By default, Timeline actions such as Stop (see ActionStop), Play (see ActionPlay), and

GoToFrame (see ActionGotoFrame) apply to files that contain them. However, the SetTarget

action (see ActionSetTarget), which is called Tell Target in the Adobe Flash user interface, can

be used to send an action command to another file or sprite (see DefineSprite).


行为(或行为列表)可以通过按钮状态转换或 SWF 3 actions 进行触发,行为不是立即被执行,而是被添加到行为列表中执行,行为列表在遇到 ShowFrame tag或按钮状态转换后时执行,这种情况下,被添加到行为列表中待执行的行为会被全部处理直到行为列表为空为止,

默认情况下,时间性行会作用于包含他们的文件,如(Stop, Play, GoToFrame等),SetTarget行为或接口名TellTarget,可以被用来给另一个SWF文件或sprite发送action command.

SWF 3 actions

The actions in this section are available in SWF 3.[行为仅适用于SWF 3版本]


ActionSetTarget instructs Flash Player to change the context of subsequent actions, so they

apply to a named object (TargetName) rather than the current file.

For example, the SetTarget action can be used to control the Timeline of a sprite object. The

following sequence of actions sends a sprite called "spinner" to the first frame in its


1. SetTarget "spinner"

2. GotoFrame zero

3. SetTarget " " (empty string)

4. End of actions. (Action code = 0)

All actions following SetTarget spinner apply to the spinner object until SetTarget “”,

which sets the action context back to the current file. For a complete discussion of target

names see DefineSprite.

ActionSetTartget 行为

ActionSetTarget 行为表明Flash Player要去改变后续actions的上下文,因此比较适合应用于named object(TargetName)而不是当前SWF文件。

例如:他和SetTarget action可以用于控制sprite object 的生命线,一下行为流程是将一个叫做spinnerSprite发送给他生命线的第一帧上。


接着SetTarget spinner”以下的所有行为都将作用于spinner object直到遇到 Set Target “”,  Set Target “”的作用是将行为上下文返回当前文件,对于target names 的详细讨论请参见DefineSprite.


SWF 4 action model

The SWF 4 file format supports a greatly enhanced action model that includes an expression

evaluator, variables, conditional branching and looping.

Flash Player 4 incorporates a stack machine that interprets and executes SWF 4 actions. The

key SWF 4 action is ActionPush. This action is used to push one or more parameters onto the

stack. Unlike SWF 3 actions, SWF 4 actions do not have parameters embedded in the tag,

rather they push parameters onto the stack, and pop results off the stack.

The expression evaluator is also stack based. Arithmetic operators include ActionAdd,

ActionSubtract, ActionMultiply, and ActionDivide. The Flash authoring tool converts

expressions to a series of stack operations. For example, the expression 1+x*3 is represented as

the following action sequence:

ActionPush "x"


ActionPush "3"


ActionPush "1"


The result of this expression is on the stack.

SWF 4与之前最大的不同就是可以将参数压入栈,像表达式计算就是基于栈来实现的。

Movie control [移动控制流]


ActionGetProperty does the following:

1. Pops index off the stack.

2. Pops target off the stack.

3. Retrieves the value of the property enumerated as index from the movie clip with target

path target and pushes the value to the stack.




3:根据target path从影片剪辑中以枚举索引值方式来获取相关属性值,并将结果压入栈中。

The following table lists property index values. The _quality, _xmouse, _ymouse and _rotation 10

properties are available in SWF 5 and later.





  • CC1991_
  • CC1991_
  • 2017年04月08日 10:58
  • 21475

谷歌翻译API, 免费采集翻译

大家都知道,以前谷歌翻译是开放免费API的,对于我们工程中即时翻译用的很方便,可是后来谷歌收费了,5555 各种不方便啊 遂 ,决定自己做个采集翻译的小工具,方便自己,也能方便大家。当然,网上的哪些所...
  • life169
  • life169
  • 2016年08月08日 19:12
  • 13696


首先要有微软账号,比如hotmail什么的https://datamarket.azure.com/developer/applications 订阅翻译服务 https://datamarket.a...
  • lnpypy
  • lnpypy
  • 2016年08月16日 14:54
  • 3332


Google翻译PDF文档 翻译软件虽多如牛毛,但有关整段/全文翻译,堪用的软件极少, 涉及专业技术的文献,胜任翻译工作的人力稀缺,少不了工程师讴心沥血; 因为多是PDF格式,即使要翻译个概要,也...
  • kobesdu
  • kobesdu
  • 2014年07月23日 13:32
  • 17576


Eclipse neon 汉化版 ; 1;右击新建 -->  选择 动态Web项目  2:  填写 项目名 项目位置 ; 选择 Dynamic web module version 和 tom...
  • Com_ma
  • Com_ma
  • 2017年10月07日 04:11
  • 170

spacemacs中用google translate翻译英文

先声明,这是英文词典,不是中英文词典。安装方式,在package system中,选择安装dictionary.重启Emacs后就可以使用。使用方法:移动到某个单词,M-x 运行dictionary-...
  • sheismylife
  • sheismylife
  • 2014年02月15日 17:47
  • 3545

IntelliJ IDEA 翻译

安装: 操作:
  • sat472291519
  • sat472291519
  • 2017年05月23日 08:40
  • 497


为vim增加自动翻译光标处的单词 查询有道在线词典解析内容
  • wangxugangzy05
  • wangxugangzy05
  • 2016年11月25日 18:49
  • 977


 2013年到现在,已经翻译了3本书了,其它杂七杂八的文章也不少。其中有一些经验和教训,势必要总结一下。 将译稿纳入版本管理 没有版本管理的代码修改起来是战战兢兢地,而译稿也类似。我习惯在G...
  • donghong2008
  • donghong2008
  • 2014年09月24日 09:35
  • 740


  • u010293844
  • u010293844
  • 2015年11月22日 18:42
  • 1025