A shape is the vector artwork of a frame or of a grouped shape. Everything here is as the JPEXS FLA converter reads and writes it, and was checked against some 1,300 real documents from Flash 3, 4, 5 and MX, every shape of which reads to the last byte. Values are little-endian.
Numbers
- A matrix is six signed 32-bit words: a, b, c, d as signed 16.16 fixed-point numbers, then tx, ty in twips (1/20 of a pixel). x′ = a·x + c·y + tx, y′ = b·x + d·y + ty.
- Edge coordinates are in 1/128 of a twip, so 2,560 to a pixel.
- A colour is four bytes in the order red, green, blue, alpha.
- Style indices count from 1; 0 means no style. The top bit of a stroke or fill index
(
0x8000) marks a selected edge.
The shape part
Classes CPicShape (a grouped shape, or the root of a stream that holds a
bare shape) and CPicFrame start with the same part: the
object part, then:
| Field | Meaning |
|---|---|
| u8 | The shape part’s revision: 2 in every file of this format seen. Later releases raise it, and from 3 it sets the shape’s mode; here the mode is always 0. |
| 6 × s32 | The shape’s matrix. |
| … | The shape data, below. |
In a CPicShape the object part’s flags byte has been seen as 0 to 3;
what its bits mean is not established.
Shape data
| Field | Present | Meaning |
|---|---|---|
| u8 | always | The data’s revision: 4 in Flash 3 and 4, 5 from Flash 5. |
| u32 | always | A count hint, equal to the number of edges in the files seen. |
| u16 + fills | always | The fill styles. Below data revision 3 each is a u32 colour and a u16 value, not established; from 3, the fill record below. |
| u16 + strokes | always | The stroke styles. |
| edges | data revision 2 or more | Edge records, ended by a zero byte. |
| u32 + cubics | data revision 5 | The cubic curves. |
Data revisions below 4 belong to Flash 1 and 2, whose files have not been examined here; the layout given for them is the JPEXS reader’s.
Fill styles
| Field | Meaning |
|---|---|
| u32 | The colour, for a solid fill (red, green, blue, alpha). |
| u8 flags | 0x10 gradient, 0x20 extended, 0x40 bitmap; none set is solid. For a gradient, 0x10 alone is linear, 0x12 radial. For a bitmap, bit 0 set is clipped and clear is tiled. |
| u8 | Secondary flags; not established. |
Values seen in this format: 00 (solid), 10 and
12 from Flash 3, 40 from Flash 4 and 41 in Flash
MX. The “not smoothed” bit (bit 1 of a bitmap fill) belongs to later releases.
Gradient (0x10)
| Field | Meaning |
|---|---|
| 6 × s32 | The gradient matrix. |
| u8 | The number of stops, up to 15. |
| n × (u8, u32) | Stops: a ratio (0 to 255) and a colour. |
The focal point and the spread and interpolation flags that Flash 8 added are not written at mode 0.
Extended fill (0x20)
Six s32 of a matrix, a u32 value, and four u16 words. JPEXS reads these but no public work states what they are used for, and none was found in this format’s files: treat the extended fill as not established.
Bitmap fill (0x40)
Six s32 of a matrix, then a u16 media number: the mediaId of a
CMediaBits record.
Stroke styles
| Field | Meaning |
|---|---|
| u32 | The colour. |
| u16 | The width in twips; 0 is a hairline. |
| u16 | Style word 1; if non-zero, the stroke is dashed and this is the dash length in twips. |
| u16 | Style word 2: bits 0 to 2 the kind (below) when style word 1 is 0; bit 15 sharp corners; the higher bits are by kind, below. |
Caps, joins, pixel hinting, scale mode and gradient strokes came with Flash 8, so a stroke here is always those four fields and a solid colour.
| Kind | Name | The rest of style word 2 (from bit 3 up) |
|---|---|---|
| 0 | solid | – |
| 1 | dashed | Style word 1 holds the dash; the gap in twips is style word 2 with bit 15 cleared. |
| 2 | dotted | Bits 3 up: the dot spacing in twips. |
| 3 | ragged | Bits 3–5 pattern (solid, simple, random, dotted, random dotted, triple dotted, random triple dotted), 6–7 wave height (flat, wavy, very wavy, wild), 8–9 wave length (very short, short, medium, long). |
| 4 | stipple | Bits 3–4 dot size (tiny, small, medium, large), 5–6 variation (one size, small variation, varied sizes, random sizes), 7–8 density (very dense, dense, sparse, very sparse). |
| 5 | hatched | Bits 3–4 thickness (hairline, thin, medium, thick), 5–6 space (very close, close, distant, very distant), 7–8 rotate (none, slight, medium, free), 9–10 jiggle (none, bounce, loose, wild), 11–12 curve (straight, slight curve, medium curve, very curved), 13–14 length (equal, slight variation, medium variation, random). |
| 6, 7 | not known | No public source names them. |
Edge records
An edge is one line or quadratic curve between two points, with the styles on either side of it. The list ends with a zero byte. Coordinates are absolute, written as changes from the previous edge’s end; the first edge starts from 0, 0.
| Field | Present | Meaning |
|---|---|---|
| u8 | always | The control byte, below. |
| 3 × u8 or u16 | control & 0x40 | The stroke, left fill and right fill style indices, u8 if control & 0x80, otherwise u16. Absent: the previous edge’s styles again. |
| delta, delta | always | The change from the last edge’s end to this edge’s start (x, y). |
| delta, delta | a curve | The control point, relative to the start. |
| delta, delta | always | The end, relative to the start. |
The line-flags byte that later releases write after a straight edge is not present in this format.
| Control bits | Meaning |
|---|---|
0x03 | The encoding of the start delta. |
0x0C | The encoding of the control delta. Non-zero makes the edge a curve. |
0x30 | The encoding of the end delta. |
0x40 | Style indices follow. |
0x80 | The style indices are u8, not u16. |
| Encoding | A delta is |
|---|---|
| 0 | Zero: nothing is stored. |
| 1 | An s16. |
| 2 | An s32. |
| 3 | An s16 shifted left seven bits (a whole number of twips). |
Cubics
Data revision 5, first written by Flash 5, ends the shape with a u32 count and that many cubic Bézier curves, each eight s32: start point, two control points and end point, in the same units as the edges. The edges above still hold the whole drawing as lines and quadratic curves, so a reader that skips the list loses nothing it needs to draw the shape; what Flash uses the list for is not documented. About one Flash 5 or MX keyframe in a hundred has any. Later releases add more fields to each entry; in this format a curve is just its eight numbers.
Morph shapes
A shape tween is held on its keyframe as a CPicMorphShape object, from
frame revision 13 (Flash 3) on:
| Field | Present | Meaning |
|---|---|---|
| u8 | always | The revision: 2 in every file seen. |
| 2 × (6 × s32) | always | The matrices of the start and end shapes. |
| u32, u32 | revision 2 | A value not established, and the acceleration. |
count + CMorphSegment | always | The segments: four s32 style indices (stroke and fill, start and end), two points (s32, s32) and a count of CMorphCurve objects. |
count + CMorphHintItem | always | Shape hints: two points and a u32 key. |
| u16 + fills, u16 + strokes | always | The tween’s styles, written as above. |
CMorphCurve: control point and anchor point of the start and end shapes
(four pairs of s32) and a u32 line flags.
A count here is a u16; if it is FFFF a u32 follows with the real count.
Each segment, curve and hint is a full object with its own
class tag.
In the explorer
The explorer reads every shape to the last byte and lists its fills, strokes and edges with their meanings: colours, gradient stops, bitmap fills by media name, stroke kinds with their pattern settings, and each edge’s points in pixels.