Made to Order Software Corporation Logo

function

Get Property

SWF Action
Action Category: 
Properties
Action Details: 
0
Action Identifier: 
34
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (n), pop 1 (s), push 1 (a)
Action Operation: 
n1 := pop();
s2 := pop();
r := s2[n1];
push(r);
Action Flash Version: 
4

Query the property n1 of the object named s2 (a field in a structure if you wish), and push the result on the stack. Note that since version 5, it is preferable to use Get Member or Call Method when a corresponding variable or function member is available on the object.

The following is the list of currently accepted properties or fields for the Get Property and the Set Property actions. Note that the properties can be specified with either an integer (type 7, requires V5.0+) or a single precision floating point (type 1, V4.0 compatible). And since strings are automatically transformed in a value when required, one can use a string to represent the property number (type 0). It works with a double value, I even tested a Boolean and null and it works. Obviously it isn't a good idea to use these. The default should be a single precision float. Please, see the Push Data action for more information about data types.

WARNING: Adobe is trying to phase out this functionality. It is very likely not working in ABC code and it is not necessary since objects have member functions that can be used for the exact same purpose and it is a lot cleaner to use those instead.

 

Float Decimal Name Comments Version
0x00000000 0 x x position in pixels (not TWIPs!) 4
0x3F800000 1 y y position in pixels (not TWIPs!) 4
0x40000000 2 x scale horizontal scaling factor in percent (50 — NOT 0.5 — represents half the normal size!!!) 4
0x40400000 3 y scale vertical scaling factor in percent (50 — NOT 0.5 — represents half the normal size!!!) 4
0x40800000 4 current frame the very frame being played; one can query the root current frame using an empty string ("") as the name of the object; note that the first current frame is number 1 and the last is equal to the total number of frames; on the other hand, the Goto instruction expects a frame number from 0 to the number of frames - 1 4
0x40A00000 5 number of frames total number of frames in movie/sprite/thread 4
0x40C00000 6 alpha alpha value in percent (50 — NOT 0.5 — means half transparent) 4
0x40E00000 7 visibility whether the object is visible 4
0x41000000 8 width maximum width of the object (scales the object to that width) 4
0x41100000 9 height maximum height of the object (scales the object to that height) 4
0x41200000 10 rotation rotation angle in degrees 4
0x41300000 11 target return the name (full path) of an object; this can be viewed as a reference to that object 4
0x41400000 12 frames loaded number of frames already loaded 4
0x41500000 13 name name of the object 4
0x41600000 14 drop target object over which this object was last dropped 4
0x41700000 15 url URL linked to that object 4
0x41800000 16 high quality whether we are in high quality mode 4
0x41880000 17 show focus rectangle whether the focus rectangle is visible 4
0x41900000 18 sound buffer time position (or pointer) in the sound buffer; useful to synchronize the graphics to the music 4
0x41980000 19 quality what the quality is (0 - Low, 1 - Medium or 2 - High) 5
0x41A00000 20 x mouse current horizontal position of the mouse pointer within the Flash window 5
0x41A80000 21 y mouse current vertical position of the mouse pointer within the Flash window 5
0x46800000 16384 clone this flag has to do with the depth of sprites being duplicated 4

FSCommand2

SWF Action
Action Category: 
Miscellaneous
Action Details: 
0
Action Identifier: 
45
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (i), pop i1 (s)
Action Operation: 
i1 := pop();
for(idx := 2; idx < i1 + 2; ++i1) {
  sidx := pop();
}
fscommand2(s2, s3, ..., s(i1 + 1));
Action Flash Version: 
8

Execute the external command (s2) passing on parameters (s3, s4 ... sn.) The external command is likely a JavaScript function.

IMPORTANT NOTES

Ammar Mardawi sent a correction for this action and it looks like it works the way it is described now.

SWF Internal Functions

Since Flash version 5, you can use internal functions (really member functions or methods of internal objects.) These functions are always available. These methods are called using the Call Function action with the name of the object and function separated by a period. A few of these internal functions are duplicates of some direct action script instructions. In general, it is preferred to use these internal functions rather than the direct action. However, direct actions are a good way to optimize your ActionScript code.

Similarly, you can access internal constants (really variable ...

Enumerate Object

SWF Action
Action Category: 
Objects
Action Details: 
0
Action Identifier: 
85
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (o), push null, push * (s)
Action Operation: 
o1 := pop();
push(null);
foreach(o1 as name) {
  push(name);
}
Action Flash Version: 
6

Pop an object from the stack, push a null, then push the name of each variable and function member of that object on the stack.

This mechanism can be used to implement a foreach() function on an object. Be careful, though, that the stack be cleared when leaving the loop.

This action uses an object reference. If you only have the name of the object, use the Enumerate action instead.

Note that internal functions, such as the play() function on a MovieClip1, are enumerated but they cannot really be dealt with easily. Their ...

  • 1. MovieClip is the proper type for a Sprite in an ActionScript.

Enumerate

SWF Action
Action Category: 
Objects
Action Details: 
0
Action Identifier: 
70
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (s), push null, push * (s)
Action Operation: 
s1 := pop();
push(null);
foreach(s1 as name) {
  push(name);
}
Action Flash Version: 
5

Pop the name of an object and push the name of all of its children (methods & variables) back on the stack. The list is null terminated.

This mechanism can be used to implement a foreach() function on an object. Be careful, though, that the stack be 100% cleared when leaving the loop.

This action uses the name of an object. If you have an object reference, use the Enumerate Object action instead.

Duplicate Sprite

SWF Action
Action Category: 
Movie
Action Details: 
0
Action Identifier: 
36
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (i), pop 2 (s)
Action Operation: 
i1 := pop();
s2 := pop();
s3 := pop();
duplicate_sprite(s3, s2, i1);
Action Flash Version: 
4

s3 is the name of an existing sprite1 which is copied by this action.

The new sprite is given  the name s2 and is placed at depth i1.

  • 1. Remember that a sprite, movie, thread and other terms that I forget, are all the same thing.

Declare Object

SWF Action
Action Category: 
Objects
Action Details: 
0
Action Identifier: 
67
Action Structure: 
<n.a.>
Action Length: 
0 byte(s)
Action Stack: 
pop 1 (i), pop i1 × 2 (a), push 1 (o)
Action Operation: 
i1 := pop();
for(idx := 2; idx <= i1 * 2 + 1; ++idx) {
  aidx := pop();
}
o := new Object;
o.a3 := a2;
o.a5 := a4;
...
o.a(i1 × 2 + 1) := a(i1 × 2);
push(o);
Action Flash Version: 
5

Pop the number of members that will be created in the object. Pop one value and one name1 per member and set the corresponding member in the object. The resulting object is pushed on the stack. It can later be sent to a function, saved in a register or set in a variable.

  • 1. The member names are converted to strings; they certainly should be strings though anything is supported.

Declare Function (V7)

SWF Action
Action Category: 
Control
Action Details: 
(256 variables)
Action Identifier: 
142
Action Structure: 
string     f_name;
unsigned short   f_arg_count;
unsigned char   f_reg_count;
unsigned short   f_declare_function2_reserved : 7;
unsigned short   f_preload_global : 1;
unsigned short   f_preload_parent : 1;
unsigned short   f_preload_root : 1;
unsigned short   f_suppress_super : 1;
unsigned short   f_preload_super : 1;
unsigned short   f_suppress_arguments : 1;
unsigned short   f_preload_arguments : 1;
unsigned short   f_suppress_this : 1;
unsigned short   f_preload_this : 1;
swf_params   f_params[f_arg_count];
unsigned short   f_function_length;

WARNING: the preload/suppress flags are defined on a short and thus the bytes in a Flash file will look swapped.

Action Length: 
-1 byte(s)
Action Stack: 
n.a.
Action Operation: 
create a function on the current target
Action Flash Version: 
7

Declare a function which can later be called with the Call Function action or Call Method action (when defined as a function member.) The f_function_length1 defines the number of bytes that the function declaration uses after the header (i.e. the size of the actions defined in the function.) All the actions included in this block are part of the function body.

  • 1. A function is limited to 65535 bytes.

Declare Function

SWF Action
Action Category: 
Control
Action Details: 
0
Action Identifier: 
155
Action Structure: 
string    f_name;
unsigned short   f_arg_count;
string   f_arg_name[f_arg_count];
unsigned short   f_function_length;
Action Length: 
-1 byte(s)
Action Stack: 
n.a.
Action Operation: 
create function f_name in the current target movie
Action Flash Version: 
5

Declare a function which later can be called with the Call Function action. The f_function_length1 defines the number of bytes that the function declaration takes. All the actions included in this block are part of the function. A function should terminate with a Return action. The value used by the return statement should be the only value left on the caller stack.

  • 1. Functions are limited to 65535 bytes in length.

Declare Dictionary

SWF Action
Action Category: 
Objects
Action Details: 
0
Action Identifier: 
136
Action Structure: 
unsigned short    f_count;
string   f_dictionary[f_count];
Action Length: 
-1 byte(s)
Action Stack: 
n.a.
Action Operation: 
<n.a.>
Action Flash Version: 
5
See Also: 

Declare an array of strings that will later be retrieved using the Push Data action with a dictionary lookup. There can be a maximum of 65534 strings. The visibility of a dictionary is within its DoAction or other similar block of actions. Note that you should have only one Declare Dictionary. The dictionary is visible from everywhere in the DoAction. In other words, you can access it from functions1, With blocks, try/catch/finally blocks, etc.

When multiple Declare Dictionary actions are used, ...