Made to Order Software Corporation Logo

function

Type Of

SWF Action
Action Category: 
Objects
Action Details: 
0
Action Identifier: 
68
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (a), push 1 (s)
Action Operation: 
a1 := pop();
r := typeof(a1);
push(r);
Action Flash Version: 
5

Pop one item from the stack, define its type and push the name of its type back on the stack.

The existing types are as follow:

number
boolean
string
object
movieclip
null
undefined
function

Note that this action does not distinguish between different user objects. All of them are object.

Try

SWF Action
Action Category: 
Control
Action Details: 
0
Action Identifier: 
143
Action Structure: 
unsigned char     f_try_reserved : 5;
unsigned char     f_catch_in_register : 1;
unsigned char     f_finally : 1;
unsigned char     f_catch : 1;
unsigned short    f_try_size;
unsigned short    f_catch_size;
unsigned short    f_finally_size;
if(f_catch_in_register == 0) {
  string                   f_catch_name;
}
else {
  unsigned char    f_catch_register;
}
Action Length: 
-1 byte(s)
Action Stack: 
n.a.
Action Operation: 
try { ... }
catch(name) { ... }
finally { ... }
Action Flash Version: 
7
See Also: 

Declare a try/catch/finally block.

This has the behavior of the action script:

	try { ... }
	catch(name) { ... }
	finally { ... }

In version 7, there are no definition of exceptions in the ActionScript interpreter. However, you can write functions that Throw.

The semantic of the try/catch/finally block is very well defined in ECMA 262 version 3 (see pages 87/88).

f_finally and f_catch may not both be zero or the semantic of the try block would be invalid. f_try_size, f_catch_size and f_finally_size are defined in bytes and give the size of each of the block of instructions just like a ...

Swap

SWF Action
Action Category: 
Stack
Action Details: 
0
Action Identifier: 
77
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 2 (a), push 2 (a)
Action Operation: 
a1 := pop();
a2 := pop();
push(a1);
push(a2);
Action Flash Version: 
5
See Also: 

Pop two items and push them back the other way around.

This action is very useful when you just called a function and need to swap that parameter with the previous function call when all you should have to do is call.

Store Register

SWF Action
Action Category: 
Variables
Action Details: 
0
Action Identifier: 
135
Action Structure: 
unsigned char   f_register;
Action Length: 
1 byte(s)
Action Stack: 
pop 1 (a), push 1 (a)
Action Operation: 
a1 := pop();
target.g_register[f_register] = a1;
push(a1);
Action Flash Version: 
5

Pop one value from the stack, push it back on the stack and also store it in one of 4 or 256 registers which number is specified in the tag (0, 1, 2 or 3 only if not in a Declare Function (V7). I tried other numbers and they don't work in SWF version 6 or older.) Until set a register has the value undefined. The value of a register can be retrieved with a Push Data action and the register type with the matching register number.

Start Drag

SWF Action
Action Category: 
Movie
Action Details: 
0
Action Identifier: 
39
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (s), pop 2 (b), if (b3) { pop 4 (n) }
Action Operation: 
s1 := pop();
b2 := pop();
b3 := pop();
if(b3) {
    n4 := pop();
    n5 := pop();
    n6 := pop();
    n7 := pop();
    s1.start_drag(b2, n4, n5, n6, n7);
}
else {
    s1.start_drag(b2);
}
Action Flash Version: 
4
See Also: 

Pop a target (sprite, movie, thread) name s1.

Pop a first Boolean b2, which, when true, means that the mouse pointer is locked to the center of the object being dragged.

Pop a second Boolean b3, which when true means that the mouse pointer is constrained to the specified rectangle1 (n4 to n7, representing y2, x2, y1, x1.)

Once this function was called, the object attached to the mouse pointer will follow the mouse until a Stop Drag action is applied or another object is defined as the object being dragged with another Start Drag.

  • 1. The rectangle is not defined when b3 is false.

Set Variable

SWF Action
Action Category: 
Variables
Action Details: 
0
Action Identifier: 
29
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (a), pop 1 (s)
Action Operation: 
a1 = pop();
s2 = pop();
*s2 := a1;
Action Flash Version: 
4

Pop one value and one string, set the variable of that name with that value.

If this instruction is executed inside a function and a local variable of that name exists, then that local variable value is changed (as long as the name is not a full path name.) Note that to make sure that you set a local variable, it is a good idea to use the Set Local Variable action instead.

Set Target

SWF Action
Action Category: 
Movie
Action Details: 
(dynamic)
Action Identifier: 
139
Action Structure: 
string   f_target;
Action Length: 
-1 byte(s)
Action Stack: 
n.a.
Action Operation: 
set_target(f_target);
Action Flash Version: 
1

If the string f_target is the empty string, then the next actions apply to the main movie.

Otherwise it is the name of a Sprite and the followings actions apply to that Sprite only.

In order to use a dynamic name for the target, use Set Target (dynamic) instead.

Set Local Variable

SWF Action
Action Category: 
Variables
Action Details: 
0
Action Identifier: 
60
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (a), pop 1 (s)
Action Operation: 
a1 := pop();
s2 := pop();
*s2 := a1;
Action Flash Version: 
5

Pop a value and a local variable name. Create or set a local variable of that name with the (initial) value as specified. The same local variable can safely be set in this way multiple times. To only declare a local variable (i.e. no default value to initialize the variable,) use the Declare Local Variable instead.

Return

SWF Action
Action Category: 
Control
Action Details: 
0
Action Identifier: 
62
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (a) [in current function], push 1 (a) [in caller's function]
Action Operation: 
[in current function]
a1 := pop();
return a1;1

[in caller's function]
push(a1);
  • 1. Since Flash player version 8, the return instruction also makes sure to clear all the data still available on the stack.
Action Flash Version: 
5

Pop one object and return it to the caller. The result is stacked on the caller's stack, not the stack of the function returning.

Note that up to version 8, your functions could push multiple entries and return all of them to the caller. Since it is not compatible anymore (and it was never supposed to work that way,) it is strongly suggested that you avoid that practice. Instead use a Declare Array action.

Random

SWF Action
Action Category: 
Arithmetic
Action Details: 
0
Action Identifier: 
48
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (n), push 1 (i)
Action Operation: 
n1 := pop();
r := random(n1);
push(r);
Action Flash Version: 
4
See Also: 

Pop one number representing the maximum value (not included) that the random() function can return, push the generated value on the stack. n1 should not be zero or negative.

Since version 5, you should use the Math.rand() member function instead of this action.