A button is a character with four states, up, over, down and hit, each drawn from other characters, and actions that run when the mouse or a key changes its state. The actions are AVM1 actions; an ActionScript 3 movie handles button events in code instead. Offsets are in the decompressed data.
DefineButton (7)
| Type | Name | Description |
|---|---|---|
| UI16 | ButtonId | The character ID |
| BUTTONRECORD[] | Characters | What each state shows |
| UI8 | CharacterEndFlag | 0 |
| ACTIONRECORD[] | Actions | Run when the button is released (pressed and released over it), ending with an End action (0) |
SWF 1. Its records have no colour transforms; DefineButtonCxform can add one.
DefineButton2 (34)
| Type | Name | Description |
|---|---|---|
| UI16 | ButtonId | The character ID |
| UB[7] | ReservedFlags | 0 |
| UB[1] | TrackAsMenu | Track as a menu: other buttons react while the mouse button is held |
| UI16 | ActionOffset | From this field to the first BUTTONCONDACTION; 0 for none |
| BUTTONRECORD[] | Characters | With colour transforms |
| UI8 | CharacterEndFlag | 0 |
| BUTTONCONDACTION[] | Actions | Actions for state changes |
SWF 3.
BUTTONRECORD
| Type | Name | Description |
|---|---|---|
| UB[2] | ButtonReserved | 0 |
| UB[1] | ButtonHasBlendMode | SWF 8: BlendMode follows (0x20) |
| UB[1] | ButtonHasFilterList | SWF 8: FilterList follows (0x10) |
| UB[1] | ButtonStateHitTest | Part of the clickable area, not drawn (0x08) |
| UB[1] | ButtonStateDown | Shown while pressed (0x04) |
| UB[1] | ButtonStateOver | Shown while the mouse is over it (0x02) |
| UB[1] | ButtonStateUp | Shown normally (0x01) |
| UI16 | CharacterID | The character to show |
| UI16 | PlaceDepth | Its depth inside the button |
| MATRIX | PlaceMatrix | Its position |
| CXFORMWITHALPHA | ColorTransform | DefineButton2 only |
| FILTERLIST | FilterList | DefineButton2, if ButtonHasFilterList; see filters |
| UI8 | BlendMode | DefineButton2, if ButtonHasBlendMode |
A record whose first byte is 0 would be the end flag, so every record has at least one state bit set.
BUTTONCONDACTION
| Type | Name | Description |
|---|---|---|
| UI16 | CondActionSize | The bytes in this record; 0 for the last |
| UB[1] | CondIdleToOverDown | |
| UB[1] | CondOutDownToIdle | |
| UB[1] | CondOutDownToOverDown | |
| UB[1] | CondOverDownToOutDown | |
| UB[1] | CondOverDownToOverUp | |
| UB[1] | CondOverUpToOverDown | |
| UB[1] | CondOverUpToIdle | |
| UB[1] | CondIdleToOverUp | |
| UB[7] | CondKeyPress | SWF 4: a key code, 0 for none |
| UB[1] | CondOverDownToIdle | |
| ACTIONRECORD[] | Actions | Ending with an End action (0) |
Read as a little-endian UI16, the conditions are:
| Value | Condition | In ActionScript |
|---|---|---|
| 0x01 | IdleToOverUp | on (rollOver) |
| 0x02 | OverUpToIdle | on (rollOut) |
| 0x04 | OverUpToOverDown | on (press) |
| 0x08 | OverDownToOverUp | on (release) |
| 0x10 | OverDownToOutDown | on (dragOut) |
| 0x20 | OutDownToOverDown | on (dragOver) |
| 0x40 | OutDownToIdle | on (releaseOutside) |
| 0x80 | IdleToOverDown | on (dragOver), with OutDownToOverDown |
| 0x100 | OverDownToIdle | on (dragOut), with OverDownToOutDown |
| value >> 9 | CondKeyPress | on (keyPress "…") |
The specification names only the state changes. The ActionScript column is the usual mapping, as decompilers such as Flasm and JPEXS use it.
CondKeyPress codes: 1 left, 2 right, 3 home, 4 end, 5 insert, 6 delete, 8 backspace, 13 enter, 14 up, 15 down, 16 page up, 17 page down, 18 tab, 19 escape; 32 to 126 the ASCII character.
DefineButtonCxform (23)
| Type | Name | Description |
|---|---|---|
| UI16 | ButtonId | A DefineButton |
| CXFORM | ButtonColorTransform | The colour transform for its characters |
SWF 2.
DefineButtonSound (17)
| Type | Name | Description |
|---|---|---|
| UI16 | ButtonId | The button |
| UI16, SOUNDINFO | ButtonSoundChar0, ButtonSoundInfo0 | OverUpToIdle: a sound ID (0 for none) and, if not 0, its SOUNDINFO |
| UI16, SOUNDINFO | ButtonSoundChar1, ButtonSoundInfo1 | IdleToOverUp |
| UI16, SOUNDINFO | ButtonSoundChar2, ButtonSoundInfo2 | OverUpToOverDown |
| UI16, SOUNDINFO | ButtonSoundChar3, ButtonSoundInfo3 | OverDownToOverUp |
SWF 2.