Made to Order Software Corporation Logo

function

Declare Array

SWF Action
Action Category: 
Objects
Action Details: 
0
Action Identifier: 
66
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (i), pop i1 (a), push 1 (array)
Action Operation: 
i1 := pop();
for(idx := 2; idx < i1 + 2; ++idx) {
  aidx := pop();
}
arr := new array(i1);
arr[0] := a2;
arr[1] := a3;
...
arr[i1 - 1] := a(i1 + 1);
push(arr);
Action Flash Version: 
5

Pops the number of elements in the array. Pop one value per element and set the corresponding entry in the array. The array is pushed on the stack. It can later be sent to a function or set in a variable.

To set the indices, use the Declare Object instead.

Chr

SWF Action
Action Category: 
String and Characters
Action Details: 
0
Action Identifier: 
51
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (i), push 1 (s)
Action Operation: 
i1 := pop();
r := chr(i1);
push(r);
Action Flash Version: 
4

Pops one integer, use it as a ASCII character and push the newly created string on the stack.

The function only works with ASCII characters: a number from 0 to 255, some of which will not work (especially 0).

To generate a USC character, use the multi-byte chr() instruction instead.

Call Method

SWF Action
Action Category: 
Control
Action Details: 
0
Action Identifier: 
82
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (s), pop 1 (o), pop 1 (i), pop i3 (a)
Action Operation: 
s1 := pop();
o2 := pop();
i3 := pop();
for(idx := 4; idx < i3 + 4; ++idx) {
  aidx := pop();
}
if(s1.length) {
  // call method s1
  r := o2.s1(a4, a5, a6...a(i3+3));
}
else {
  // call constructor o2
  r := o2(a4, a5, a6...a(i3+3));
}
push(r);
Action Flash Version: 
5

Pop the name of a method (can be the empty string), pop an object, pop the number of arguments, pop each argument, call the method (function) of the object, push the returned value on the stack.

When the string is empty, the constructor is called. This is used by the system right after a new operator was called and most of the time the return value is simply discarded.

Call Function

SWF Action
Action Category: 
Control
Action Details: 
0
Action Identifier: 
61
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (s), pop 1 (i), pop i2 (a), push 1 (a)
Action Operation: 
s1 := pop();
i2 := pop();
for(idx := 3; idx < i2 + 3; ++idx) {
  aidx = pop();
}
r := call s1(a3, a4, a5...a(i2+2));
push(r);
Action Flash Version: 
5

Pops one string that represents the name of the function to call, pop one integer indicating the number of arguments following, pop each argument, call the named function, push the result of the function on the stack. There is always a result1.

  • 1. When nothing is returned by the function, the result undefined is pushed on the stack.

Appendix B — History of the SSWF reference

Dec 2, 2009

Moved the monolithic documentation to a multi-page hierarchical document that includes everything we had before plus many links, many terms attached to all pages (tags, English words.) And revision of most of the text for better English and clarification in some places.

Strengthen the formatting with CCK fields so all declarations look alike.

Broken up the actions from one large table to a set of pages.

Dec 14, 2008

Started work on the Load() feature of the SSWF library. This helped fixing several small mistakes in the documentation.

May 18, 2008

Fixed the ...

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.

End (action)

SWF Action
Action Category: 
Miscellaneous
Action Details: 
0
Action Identifier: 
0
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
0
Action Operation: 
<n.a.>
Action Flash Version: 
1
See Also: 
End

End a record of actions. There are no valid instances where this action is optional.

The End action itself as no meaning other than marking the end of the list of actions. Yet, if reached, the execution of the script ends and is considered complete.

IMPORTANT NOTE

SWF Any Filter (swf_any_filter)

SWF Structure Info
Tag Flash Version: 
8
SWF Structure: 
/* the filter type */
struct swf_filter_type {
	unsigned char	f_type;
};

struct swf_filter_glow {
	swf_filter_type	f_type;		/* 0, 2, 3, 4 or 7 */
	if(f_type == GradientGlow || f_type == GradientBevel) {
		unsigned char		f_count;
	}
	else {
		f_count = 1;
	}
	swf_rgba		f_rgba[f_count];
	if(f_type == Bevel) {
		swf_rgba		f_highlight_rgba[f_count];
	}
	if(f_type == GradientGlow || f_type == GradientBevel) {
		unsigned char		f_position[f_count];
	}
	signed long fixed	f_blur_horizontal;
	signed long fixed	f_blur_vertical;
	if(f_type != Glow) {
		signed long fixed	f_radian_angle;
		signed long fixed	f_distance;
	}
	signed short fixed	f_strength;
	unsigned		f_inner_shadow : 1;
	unsigned		f_knock_out : 1;
	unsigned		f_composite_source : 1;
	if(f_type == Bevel) {
		unsigned		f_on_top : 1;
	}
	else {
		unsigned		f_reserved : 1;
	}
	if(f_type == GradientGlow || f_type == GradientBevel) {
		unsigned		f_passes : 4;
	}
	else {
		unsigned		f_reserved : 4;
	}
};

struct swf_filter_blur {
	swf_filter_type		f_type;	/* 1 */
	unsigned long fixed	f_blur_horizontal;
	unsigned long fixed	f_blur_vertical;
	unsigned		f_passes : 5;
	unsigned		f_reserved : 3;
};

struct swf_filter_convolution {
	swf_filter_type	f_type;		/* 5 */
	unsigned char	f_columns;
	unsigned char	f_rows;
	long float	f_divisor;
	long float	f_bias;
	long float	f_weights[f_columns × f_rows];
	swf_rgba	f_default_color;
	unsigned	f_reserved : 6;
	unsigned	f_clamp : 1;
	unsigned	f_preserve_alpha : 1;
};

struct swf_filter_colormatrix {
	swf_filter_type	f_type;		/* 6 */
	long float	f_matrix[20];
};

struct swf_any_filter {
	swf_filter_type			f_fitler_type;
	swf_filter_blur			f_filter_blur;
	swf_filter_colormatrix		f_filter_colormatrix;
	swf_filter_convolution		f_filter_convolution;
	swf_filter_glow			f_filter_glow;
};

A filter defines how to transform the objects it is attached to. The first byte is the filter type. The data following depend on the type. Because each filter is much different, they are defined in separate structures. You can attach a filter to an object using an ActionScript or the PlaceObject3 tag.

The following describes the different filters available since version 8.

...
Value Name Version
0 Drop Shadow 8

[un]signed

Tag Flash Version: 
1
Used by PushData Action: 
Not available in PushData Action

A signed or unsigned bit field which width does not directly correspond to an existing C type.

In structures, the width of the field is specified after the field name like in C bit fields. In case of Flash, it can be dynamic in which case a variable name is specified.

Signed bit fields have an implied sign extend of the most significant bit of the bit field. So a signed bit field of 2 bits support the following values:

DefineShape

Tag Info
Tag Number: 
2
Tag Type: 
Define
Tag Flash Version: 
1
Brief Description: 

Define a simple geometric shape.

Tag Structure: 
struct swf_defineshape {
	swf_tag				f_tag;		/* 2, 22, 32, 46, 83, or 84 */
	unsigned short			f_shape_id;
	swf_rect			f_rect;
	is_morph = f_tag == DefineMorphShape || f_tag == DefineMorphShape2;
	has_strokes = f_tag == DefineShape4 || f_tag == DefineMorphShape2;
	if(is_morph) {
		swf_rect			f_rect_morph;
	}
	if(has_strokes) {
		swf_rect			f_stroke_rect;
		if(is_morph) {
			swf_rect			f_stroke_rect_morph;
		}
		unsigned			f_define_shape_reserved : 6;
		unsigned			f_define_shape_non_scaling_strokes : 1;
		unsigned			f_define_shape_scaling_strokes : 1;
	}
	if(is_morph) {
		unsigned long			f_offset_morph;
		swf_morph_shape_with_style	f_morph_shape_with_style;
	}
	else {
		swf_shape_with_style		f_shape_with_style;
	}
};

These are probably the most important tags in this reference. They are used to define a shape using Bezier curves and lines with different styles. The DefineShape of V1.0 is usually enough unless you need a large number of styles or you want to specify colors with an alpha channel (RGBA).