Generate a swf file, Display list (below)

000000 46 57 53 03 4F 00 00 00 78 00 05 5F 00 00 0F A0
000010 00 00 0C 01 00 43 02 FF FF FF BF 00 23 00 00 00
000020 01 00 70 FB 49 97 0D 0C 7D 50 00 01 14 00 00 From the beginning of the line 00 to the background
000030 00 01 25 C9 92 0D 21 ED 48 87 65 30 3B 6D E1 D8, the end of the color part is shape
000040 B4 00 00 86 06 06 01 00 01 00 00 40 00 00 00" The "body" part 35bytes is



followed by a new type (with a dark background, changing the color to indicate that an item is finished). Continue to look at the format definition:

project

 Types of

Description

FillStyles

FILLSTYLEARRAY 

An array of fill styles

LineStyles

LINESTYLEARRAY

Array of line styles

NumFillBits

UB[4]

The number of bits used by fill index. Refer back

NumLineBits

UB[4]

The number of bits used by the line index. Refer back

ShapeRecords

SHAPERECORD (one or more)

Refer back


The first item FILLSTYLEARRAY 00   ...... Oh, check!

 project

 Types of

Description 

FillStyleCount

 UI8

FillStyles is an array, this item indicates how many elements the array has

FillStyleCountExtended

 If the value of FillStyleCount is 0xFF UI16

If the number of elements is more than 127, use this term to indicate

FillStyles

 FILLSTYLE[FillStyleCount]

Array of fill styles 


In this example, FillStyleCount = 0 , so there is nothing to follow .

The second item LINESTYLEARRAY 01 14 00 00 00 ...... Oh, check again!

project

 Types of

Description 

LineStyleCount

 UI8

LineStyles is an array, this item indicates how many elements the array has

LineStyleCountExtended

 If the value of LineStyleCount is 0xFF UI16

If the number of elements is more than 127, use this term to indicate

LineStyles

 FILLSTYLE[FillStyleCount]

Array of line styles 


Here LineStyleCount = 1 means there is a LineStyles . Then we have to look at the elements of the LineStyles array:

project

Types of 

Description 

Width

UI16

Line width 

Color

RGB/RGBA

The color of the line, if it is shape1, shape2 is RGB; if it is shape3, it is RGBA, and A is Alpha


这里宽是 20 twips 1像素,DefineShape tag表示了这是shape1(另有DefineShape2DefineShape3请参考样式书),所以颜色是0,黑色。

回到SHAPEWITHSTYLE的下一项01 NumFillBits 0,NumLineBits

接下来是ShapeRecords 25 C9 92 0D 21 ED 48 87 65 30 3B 6D E1 又是一个新类型,而且比较复杂。可以有四种:ENDSHAPERECORDSTYLECHANGERECORDSTRAIGHTEDGERECORDCURVEDEDGERECORD
ENDSHAPERECORD定义了一个ShapeRecords 的结束。
STYLECHANGERECORD定义了填充样式,线条样式,位置的变化等。
STRAIGHTEDGERECORD 和 CURVEDEDGERECORD 分别定义了直线的边和曲线的边(在flash中的shape是矢量图形,有关矢量图形,建议参考一下SVG标准,我的书签中有一个链接)

我真的不想看下去了!我就找个借口请想看的人自己看下去吧。总之,这些打着背景色的数字定义了一个图形,的id是1,至于图形是什么,数据量有多么大,和下面的部分无关。

接下来是一个控制块,还记得三部曲吗?这是第二步。(发表的日志最后一部分变成了乱的,导致心情不好。我也要偷工减料)
86 06 tag header 拆出来的结果是 0x0686 = 0000 0110 10  00 0110前面的10位表示类型26PlaceObject2,这是一个短格式,长度用后6位表示是 6 bytes
PlaceObject2的格式定义如下(偷工减料就在这里了,直接考了~~~~大家E文都蛮好,无所谓咯)
Field                      Type            Comment
Header                     RECORDHEADER    Tag type = 26.

PlaceFlagHasClipActions    UB[1]           是否包含剪辑动作
                                           SWF 5 or later: has clip
                                           actions (sprite characters
                                           only).Otherwise: always 0.
PlaceFlagHasClipDepth      UB[1]           是否包含mask深度。
PlaceFlagHasName           UB[1]           是否自定义名称
PlaceFlagHasRatio          UB[1]           是否含有比例(补间)
PlaceFlagHasColorTransform UB[1]           是否含有颜色转换
PlaceFlagHasMatrix         UB[1]           是否含有转换矩阵
PlaceFlagHasCharacter      UB[1]           是否含有需要现实的对象
PlaceFlagMove              UB[1]           对象是否移动(补间)
下面有一些不一定有,如果上面的标志位是0,则没有相应的项(看颜色)
Depth                      UI16            深度.
CharacterId                UI16            需要显示的对象ID
Matrix                     MATRIX          转换矩阵.
ColorTransform             CXFORMWITHALPHA 颜色转换.
Ratio                      UI16            比例
Name                       STRING          自定义名称.
ClipDepth                  UI16            mask深度
ClipActions                CLIPACTIONS     剪辑动作的脚本数据.

06    PlaceObject28个标志位,组成一个字节。有关这些标志位的意义请参考样式书。
01 00 表示深度是 1
01 00 表示需要放入display list的对象id 1
00    表示的是一个转换矩阵,00说明这个矩阵是空的,即没有位移,缩放或者旋转。

剩下还有一点儿,40 00 ShowFrame tag,一个只有tag headercontrol块。它的类型是1。最后是00 00 end tag,它的类型是0

现在可以回顾一下了:我见到字典了吗?没有。字典是一个player维护的表,在swf中只是概念性的,所以我需要注意,也是我能注意的只是给每一个定义分配唯一的id标志。display list也一样,是一个概念。

流程也很清楚了:定义,控制,
ShowFrame,等待下一贞(由贞频决定等待的时间)。

压缩是一个问题,不过对程序员来说不是。如果你是java程序员,一定不会对java.util.zip包陌生。而swf采用zlib压缩,那个包正好拿来就用。只是注意不要连swf文件的header一起压缩了就好了,最后还不要忘了把第一个字节该成C

Guess you like

Origin blog.csdn.net/panpanloveruth/article/details/7041317