Made to Order Software Corporation Logo

SWF

SWF Zone Array (swf_zone_array)

SWF Structure Info
Tag Flash Version: 
8
SWF Structure: 
struct swf_zone_array {
	unsigned char		f_zone_count;		/* always 2 in V8.0 */
	swf_zone_data		f_zone_data[f_zone_count];
	/* I inverted the bits below, but I'm not too sure what is correct, do you know? */
	unsigned		f_reserved : 6;
	unsigned		f_zone_y : 1;		/* probably always 1 in V8.0 */
	unsigned		f_zone_x : 1;		/* probably always 1 in V8.0 */
};

An array of alignment zones defines hints about glyphs defined in a DefineFont3.

The f_zone_count specifies how many zones are defined in a zone array. In version 8 of SWF, the count must be set to 2.

The f_zone_data is an array of zones, each defining a position and a size.

SWF Params (swf_params)

SWF Structure Info
Tag Flash Version: 
7
SWF Structure: 
struct swf_params {
	unsigned char		f_param_register;
	string			f_param_name;
};

Since version 7 of SWF, there is a new way to create a function allows you to not only name parameters but also to put their content in a register. This is done by specifying a register number along an (optional) parameter name.

The f_param_register specifies whether the corresponding parameter will be saved in1:

  • 1. Note that "neither" is not an option, thus although both the register number and name are optional, at least one of them needs to be defined.

SWF Envelope (swf_envelope)

SWF Structure Info
Tag Flash Version: 
1
SWF Structure: 
struct swf_envelope {
	unsigned long		f_position;
	unsigned short		f_volume_left;
	unsigned short		f_volume_right;
};

When playing back a sound effect it is possible to modulate the sound to generate different effects (such as a fade in and out). The following defines the stereo volume of the sound.

The position is always given as if the sample data was defined with a rate of 44,100 bytes per seconds. For instance, the sample number 1 in a sound effect with a sample rate of 5.5K is given as position 8 in the envelope. All of these positions should be within the f_in_point and f_out_point.

SWF Sound Info (swf_sound_info)

SWF Structure Info
Tag Flash Version: 
1
SWF Structure: 
struct swf_soundinfo {
	unsigned short		f_sound_id_ref;
	unsigned		f_reserved : 2;
	unsigned		f_stop_playback : 1;
	unsigned		f_no_multiple : 1;
	unsigned		f_has_envelope : 1;
	unsigned		f_has_loops : 1;
	unsigned		f_has_out_point : 1;
	unsigned		f_has_in_point : 1;
	if(f_has_in_point) {
		unsigned long	f_in_point;
	}
	if(f_has_out_point) {
		unsigned long	f_out_point;
	}
	if(f_has_loop_count) {
		unsigned short	f_loop_count;
	}
	if(f_has_envelope) {
		unsigned char	f_envelope_count;
		swf_envelope	f_envelope[f_envelope_count];
	}
};

Information on how to playback a sound effect. These are found in a StartSound and a DefineButtonSound.

The f_sound_id_ref is a reference to an earlier DefineSound tag.

SWF External (swf_external)

SWF Structure Info
Tag Flash Version: 
3
SWF Structure: 
struct swf_external {
	unsigned short		f_object_id;
	string			f_symbol_name;
};

An external reference is a per of entries: an identifier and a name. The name is called the external symbol and is used to match the necessary definitions between two movies using Export, Import and Import2

SWF Condition (swf_condition)

SWF Structure Info
Tag Flash Version: 
1
SWF Structure: 
struct swf_condition {
	unsigned short		f_condition_length;1
	unsigned		f_condition_key : 7;
	unsigned		f_condition_menu_leave : 1;
	unsigned		f_condition_menu_enter : 1;
	unsigned		f_condition_pointer_release_ouside : 1;
	unsigned		f_condition_pointer_drag_enter : 1;
	unsigned		f_condition_pointer_drag_leave : 1;
	unsigned		f_condition_pointer_release_inside : 1;
	unsigned		f_condition_pointer_push : 1;
	unsigned		f_condition_pointer_leave : 1;
	unsigned		f_condition_pointer_enter : 1;
	swf_action		f_action_record[variable];
};
  • 1. The number of actions is variable, the f_condition_length parameter indicates the number of bytes and can be used to skip one condition and all of its actions at once. The action array must always be terminated by an End action entry (i.e 0x00).

A condition is defined in a DefineButton2 tag. It is a record of conditions. The record terminates when the size of the current (i.e. last) condition is zero. The length of that condition can be deduced from the total size of the tag minus the offset where the condition starts. Conditions are similar to events.

The f_key field represents a key code since version 4. The following table gives the code equivalence. Note that 0 means no key.

SWF Actions

The pages defined below include all the actions defined in Flash.

Different actions are supported in different version, so please, look at the version when attempting to use that action.

Some actions have been deprecated and should not be used in newer version of Flash (mainly the untyped operators.)

There are two schemes supported in Flash 9 and over: ActionScript 2 and 3 (also referenced as AS2 and AS3.)

SWF Event (swf_event)

SWF Structure Info
Tag Flash Version: 
1
SWF Structure: 
struct swf_event {
	char align;
	if(version >= 6) {
		unsigned	f_event_reserved : 13;
		if(version >= 7) {
			unsigned	f_event_construct : 1;
		}
		else {
			unsigned	f_event_reserved : 1;
		}
		unsigned	f_event_key_press : 1;
		unsigned	f_event_drag_out : 1;
		unsigned	f_event_drag_over : 1;
		unsigned	f_event_roll_out : 1;
		unsigned	f_event_roll_over : 1;
		unsigned	f_event_release_outside : 1;
		unsigned	f_event_release : 1;
		unsigned	f_event_press : 1;
		unsigned	f_event_initialize : 1;
	}
	else {
		unsigned	f_event_reserved : 7;
	}
	unsigned		f_event_data : 1;
	unsigned		f_event_key_up : 1;
	unsigned		f_event_key_down : 1;
	unsigned		f_event_mouse_up : 1;
	unsigned		f_event_mouse_down : 1;
	unsigned		f_event_mouse_move : 1;
	unsigned		f_event_unload : 1;
	unsigned		f_event_enter_frame : 1;
	unsigned		f_event_onload : 1;
	unsigned long		f_event_length;1
	swf_action		f_action_record[variable];
};
  • 1. The number of actions is variable, the f_event_length parameter indicates the number of bytes and can be used to skip all the actions at once. The action array must always be terminated by an End action entry.

An event is defined in a PlaceObject2 tag. It is a record of events terminated with a set of zero flags. Events are similar to conditions.

SWF Button (swf_button)

SWF Structure Info
Tag Flash Version: 
1
SWF Structure: 
struct swf_button {
	char align;
	unsigned		f_button_reserved : 2;
	if(version >= 8) {
		unsigned		f_button_blend_mode : 1;
		unsigned		f_button_filter_list : 1;
	}
	else {
		unsigned		f_button_reserved : 2;
	}
	unsigned		f_button_state_hit_test : 1;
	unsigned		f_button_state_down : 1;
	unsigned		f_button_state_over : 1;
	unsigned		f_button_state_up : 1;
	if(any f_button_state_... != 0) {
		unsigned short		f_button_id_ref;
		unsigned short		f_button_layer;
		swf_matrix		f_matrix;
		if(f_tag == DefineButton2) {
			swf_color_transform		f_color_transform;
		}
		if(f_button_filter_list) {
			unsigned char		f_filter_count;
			swf_any_filter		f_filter;
		}
		if(f_button_blend_mode) {
			unsigned char		f_blend_mode;
		}
	}
};

A button structure defines a state and a corresponding shape reference. The shape will be affected by the specified matrix whenever used.

There are many acceptable combinations. The object which is referenced is drawn when its state matches the current state of the button. If only the f_button_state_hit_test is set, then the shape is always displayed.

SWF Action 3 (swf_action3)

SWF Structure Info
Tag Flash Version: 
9
SWF Structure: 

Not documented here yet.

Since Flash version 9, actions can be saved in a new format named abcFormat by the Tamarin project from the Mozilla organization.

The code itself (action script) is the same, but the structure of an swf_action3 holds object oriented information about classes, methods and such in a really clean way (really! in comparison to the old way, that's dead clean!).

At this time, the swf_action3 structure is documented in the abcFormat.html file.

I will duplicate and test the structures at a later time.