| Introduction | Basic Types | Display List | Control Tags |
| Shapes | (Examples Shapes) | Gradients | Buttons |
| Sprites | Fonts and Text | Shape Morphing | Bitmap |
| Sounds | Actions | ActionScripts | Reference |
The 32-bit value 0x456e7120 is stored as: 20 71 6e 45The Flash Format SDK isolates you from endian issues. The methods OutputByte, OutputWord, OutputDWord of the FSWFStream class, always write integer values in the little-endian format
The 16-bit value 0xe712 is stored as: 12 e7
Integer Types Type Comment SI8 Signed 8-bit integer value SI16 Signed 16-bit integer value SI32 Signed 32-bit integer value SI8[n] Signed 8-bit array n is number of array elements SI16[n] Signed 16-bit array n is number of array elements UI8 Unsigned 8-bit integer value UI16 Unsigned 16-bit integer value UI32 Unsigned 32-bit integer value UI8[n] Unsigned 8-bit array n is number of array elements UI16[n] Unsigned 16-bit array n is number of array elements UI32[n] Unsigned 32-bit array n is number of array elements
|
For example:
The real value 7.5 is equivalent to: 0007.8000
Which is equal to the 32-bit value: 0x00078000
Which is stored in the MACROMEDIA FLASH (SWF) file as: 00 80 07 00
FIXED Type Comment FIXED 32-bit 16.16 fixed-point number
|
The bit stream begins with a 6-bit value (BV1) followed by a 5-bit value (BV2) which is spread across Byte1 and Byte2. BV3 is spread across Byte2 and Byte3, while BV4 is wholly contained within Byte3. Byte 5 contains two bit values; BV7 and BV8. BV9 is followed by a byte-aligned type ( UI16 ) so the last four bits of Byte6 are padded with zeros.
Byte1--- Byte2--- Byte3--- Byte4--- Byte5--- Byte6--- Byte7--- Byte8---
010110 10100 100100 1011 11001000 110 10111 001 1001 0000 0100110010101101 BV1---BV2--BV3---BV4-BV5-----BV6BV7--BV8BV9-pad-UI16------------
When an unsigned bit value is expanded into a larger word size the leftmost bits are filled with zeros. When a signed bit value is expanded into a larger word size the high bit is copied to the left most bits.
Bit Values Type Comment SB[nBits] Signed bit value (nBits is the number of bits used to store the value) UB[nBits] Unsigned bit value (nBits is the number of bits used to store the value) FB[nBits] Signed fixed-point bit value (nBits is the number of bits used to store the value)
|
The nBits field determines the number of bits used to store the coordinate values Xmin, Xmax, Ymin, and Ymax. Say the coordinates of the rectangle were as follows:
RECT Field Type Comment Nbits nBits = UB[5] Bits in each rect value field Xmin SB[nBits] X minimum position for rect Xmax SB[nBits] X maximum position for rect Ymin SB[nBits] Y minimum position for rect Ymax SB[nBits] Y maximum position for rect
Xmin = 127 decimal = 1111111 binaryNbits is calculated by finding the coordinate that requires the most bits to represent. In this case that value is 514 (01000000010 binary) which requires 11 bits to represent. So the rectangle is stored as below:
Xmax = 260 decimal = 10000100 binary
Ymin = 15 decimal = 1111 binary
Ymax = 514 decimal = 1000000010 binary
RECT Field Type Comment Nbits UB[5] = 1011 Bits required (11) Xmin SB[11] = 00001111111 X minimum in twips (127) Xmax SB[11] = 00010000100 X maximum in twips (260) Ymin SB[11] = 00000001111 Y minimum in twips (15) Ymax SB[11] = 01000000010 Y maximum in twips (514)
STRING Field Type Comment String UI8[zero or more] Non-null string character data StringEND UI8 Marks end of string always zero
|
RGB Field Type Comment Red UI8 Red color value Green UI8 Green color value Blue UI8 Blue color value
|
RGB Field Type Comment Red UI8 Red color value Green UI8 Green color value Blue UI8 Blue color value Alpha UI8 Transparency color value
|
RECT Field Type Comment Nbits nBits = UB[5] Bits used for each subsequent field Xmin SB[nBits] X minimum position for rectangle in twips Xmax SB[nBits] X maximum position for rectangle in twips Ymin SB[nBits] Y minimum position for rectangle in twips Ymax SB[nBits] Y maximum position for rectangle in twips
|
The ScaleX, ScaleY, RotateSkew0 and RotateSkew1 fields are stored as 16.16 fixed-point values. The TranslateX and TranslateY values are stored as signed values in twips.
MATRIX Field Type Comment HasScale hasScale = UB[1] Has scale values if equal to 1 NScaleBits If hasScale nScaleBits = UB[5] Bits in each scale value field ScaleX If hasScale FB[nScaleBits] X scale value ScaleY If hasScale FB[nScaleBits] Y scale value HasRotate hasRotate = UB[1] Has rotate and skew values if equal to 1 NRotateBits If hasRotate nRotateBits = UB[5] Bits in each rotate value field RotateSkew0 If hasRotate FB[nRotateBits] First rotate and skew value RotateSkew1 If hasRotate FB[nRotateBits] Second rotate and skew value NTranslateBits nTranslateBits = UB[5] Bits in each translate value field TranslateX SB[nTranslateBits] X translate value in twips TranslateY SB[nTranslateBits] Y translate value in twips
quoting openswf.org: The start of a MATRIX record must be byte-aligned.
| ScaleX RotateSkew0 |For any coordinates (x, y), the transformed coordinates (x', y') are calculated as follows:
| RotateSkew1 ScaleY |
| TranslateX TranslateY |
x' = x * ScaleX + y * RotateSkew1 + TranslateXThe following table describes how the members of the matrix are used for each type of operation:
y' = x * RotateSkew0 + y * ScaleY + TranslateY
|
|
|
R' = (R * RedMultTerm) / 256Addition transforms simply add an addition term (positive or negative) to the red, green and blue components of the object being displayed. If the result is greater than 255, the result is clamped to 255. If the result is less than zero, the result is clamped to zero.
G' = (G * GreenMultTerm) / 256
B' = (B * BlueMultTerm) / 256
R' = max(0, min(R + RedAddTerm, 255))Addition and Multiplication transforms can be combined as below. The multiplication operation is performed first.
G' = max(0, min(G + GreenAddTerm, 255))
B' = max(0, min(B + BlueAddTerm, 255))
R' = max(0, min(((R * RedMultTerm) / 256) + RedAddTerm, 255))
G' = max(0, min(((G * GreenMultTerm) / 256) + GreenAddTerm, 255))
B' = max(0, min(((B * BlueMultTerm) / 256) + BlueAddTerm, 255))
quoting openswf.org: The start of a CXForm record must be byte-aligned.
CXFORM Field Type Comment HasAddTerms hasAdd = UB[1] Has color addition values if equal to 1 HasMultTerms hasMult = UB[1] Has color multiply values if equal to 1 Nbits nBits = UB[4] Bits in each value field RedMultTerm If hasMult SB[nBits] Red multiply value GreenMultTerm If hasMult SB[nBits] Green multiply value BlueMultTerm If hasMult SB[nBits] Blue multiply value RedAddTerm If hasAdd SB[nBits] Red addition value GreenAddTerm If hasAdd SB[nBits] Green addition value BlueAddTerm If hasAdd SB[nBits] Blue addition value
|
|
R' = (R * RedMultTerm) / 256The CXFORMWITHALPHA record is most commonly used to display objects as partially transparent. This is achieved by multiplying the alpha channel by some value between zero and 256.
G' = (G * GreenMultTerm) / 256
B' = (B * BlueMultTerm) / 256
A' = (A * AlphaMultTerm) / 256
R' = max(0, min(R + RedAddTerm, 255))Addition and Multiplication transforms can be combined as below. The multiplication operation is performed first.
G' = max(0, min(G + GreenAddTerm, 255))
B' = max(0, min(B + BlueAddTerm, 255))
A' = max(0, min(A + AlphaAddTerm, 255))
R' = max(0, min(((R * RedMultTerm) / 256) + RedAddTerm, 255))
G' = max(0, min(((G * GreenMultTerm) / 256) + GreenAddTerm, 255))
B' = max(0, min(((B * BlueMultTerm) / 256) + BlueAddTerm, 255))
A' = max(0, min(((A * AlphaMultTerm) / 256) + AlphaAddTerm, 255))
quoting openswf.org: The start of a CXFormWithAlpha record must be byte-aligned.
CXFORMWITHALPHA Field Type Comment HasAddTerms hasAdd = UB[1] Has color addition values if equal to 1 HasMultTerms hasMult = UB[1] Has color multiply values if equal to 1 Nbits nBits = UB[4] Bits in each value field RedMultTerm If hasMult SB[nBits] Red multiply value GreenMultTerm If hasMult SB[nBits] Green multiply value BlueMultTerm If hasMult SB[nBits] Blue multiply value AlphaMultTerm If hasMult SB[nBits] Alpha multiply value RedAddTerm If hasAdd SB[nBits] Red addition value GreenAddTerm If hasAdd SB[nBits] Green addition value BlueAddTerm If hasAdd SB[nBits] Blue addition value AlphaAddTerm If hasAdd SB[nBits] Alpha addition value
|
|
| Introduction | Basic Types | Display List | Control Tags |
| Shapes | (Examples Shapes) | Gradients | Buttons |
| Sprites | Fonts and Text | Shape Morphing | Bitmap |
| Sounds | Actions | ActionScripts | Reference |