S > set
setSyntax
variable
=
expression
;
set(
variable
,
expression
);
Arguments
variable
The name of the container that holds the value of the expression
argument.
expression
The value (or a phrase that can be evaluated to a value) that is assigned to the variable.
Description
Action; assigns a value to a variable. A variable is a container that holds information. The container itself is always the same, but the contents can change. By changing the value of a variable as the movie plays, you can record and save information about what the user has done, record values that change as the movie plays, or evaluate whether a condition is true
or false
.
Variables can hold either numbers or strings of characters. Each movie and movie clip has its own set of variables, and each variable has its own value independent of variables in other movies or movie clips.
ActionScript is an untyped language. That means that variables do not need to be explicitly defined as containing either a number or a string. Flash interprets the data type as an integer or string accordingly.
Use the set
statement in conjunction with the call
action to pass or return values.
Player
Flash 4 or later.
Example
This example sets a variable called orig
_x_pos
that stores the original x axis position of the ship
movie clip in order to reset the ship to its starting location later in the movie:
on(release) { set(x_pos, getProperty ("ship", _x )); }
This is equivalent to writing the following:
on(release) { orig_x_pos = getProperty ("ship", _x ); }
See also
var
call