variable(string)
Top  Previous  Next


SWiSH Player Support
SWF5 or later - Supported Internally

Syntax
1. variable(string); or
2. variable(string) = expression;

Arguments
string: A string containing the name of a variable.
expression: Any valid expression.

Returns
Value of the variable defined by the string (mode 1).

Description
1. Function: Accesses variables, by name. If the expression is a variable or a property, the value of the variable or property is returned. In this mode it is equivalent to eval().

2. Function: Allows the variable specified within the string to be assigned the value defined by the expression.

Sample
The following example uses the eval function to determine the value of the expression "piece" + x. Because the result is a variable name, piece3, the eval function returns the value of the variable and assigns it to y:

Item5 = "test";
x = 5

y = variable("Item" add x);
trace(y); // Output: test this demonstrates function 1

variable(Item5) = "hi"
trace(test);   // output: "hi", new variable test is created. This demonstrates function 2