File Compression Strategy
文件压缩策略
Since SWF files are frequently delivered over a network connection, it is important that they be as
compact as possible. There are several techniques that are used to accomplish this. Here are some
things to look out for:
既然SWF文件在网络连接中传输得非常频繁,那它们当然是越紧凑越好。有很多技术可以实现这点。这是我们选中的几种有效的策略:
Reuse The structure of the character dictionary makes it very easy to reuse elements in a SWF
file. For example, a shape, button, sound, font, or bitmap can be stored in a file once and
referenced many times.
重用 角色字典的结构使得重用SWF文件元素非常容易。例如,一个形体、按钮、声音、字体或者位图,可以在文件中只存一次,但用到很多次。
Compression Shapes are compressed using a very efficient delta encoding scheme, often the
first coordinate of a line is assumed to be the last coordinate of the previous one. Distances are
also often expressed relative to the last position.
压缩 形体使用了非常有效的差值编码方法来压缩,经常直线的开始坐标是上一条直线的最终坐标。距离经常由上一个位置的坐标来表达。
Default values Some structures like matrices and color transforms have common fields that are
used more often than others. For example, for a matrix, the most common field is the translation
field. Scaling and rotation are less common. Therefore if the scaling field is not present, it is
assumed to be 100%. If the rotation field is not present, it is assumed that there is no rotation.
This use of default values helps to minimize file sizes.
默认值 有一些结构像矩阵和色彩变换都有一些共同的属性用得比其它的多。比如一个矩阵,最常用的属性就是平移属性,而缩放与旋转则用得相对少点。因此如果没有定义缩放属性,就假定它的值为100%,如果没有定义旋转属性,就假定它的值为没有旋转。使用默认值可以使文件大小最小化。
Change Encoding As a rule, SWF files only store the changes between states. This is reflected
in shape data structures and in the place/move/remove model used by the display list.
变化编码 作为一种规则,SWF文件只存储两种状态之间的变化。它由形体数据结构和播放列表中使用的定位/移动/移除模块反映出来。
Shape Data Structure The shape data structure uses a unique structure to minimize the size of
shapes and to render anti-aliased shapes very efficiently on the screen.
形体数据结构 形体数据结构使用了一种独特的结构,使得形体的文件大小最小化,并且使得形体在屏幕上的平滑抗锯齿处理非常有效。
Summary
小结
A SWF file is made up of a header, followed by a number of tags. There are two types of tags,
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 movie.
一个SWF文件是由一个文件头,跟着一系列的标签组成的。标签类型有两种:定义型标签和控制型标签。定义型标签把所有物体定义成一个个角色,这些角色存在字典里面。控制型标签操作这些角色,并且控制影片的流程。