Using Director > Using Interactive Media Types > Using Lingo to set and test Flash 4 variables |  |

Using Lingo to set and test Flash 4 variables

Two new sprite functions have been added to support variables in Flash 4 sprites: `getVariable()` and `setVariable()`. Also, a return value has been added to the `hitTest()` function.

To return a string that contains the current value of a Flash sprite variable, use the following statement:

    getVariable( sprite X, variableName )

To set the current value of a Flash sprite variable to a specified string, use the following statement:

    setVariable( sprite X, variableName, newValue )

Note: Be sure to pass the Flash variable's name as a string in both the `getVariable` and`setVariable` functions. Failure to do so will result in script errors being produced when the functions are executed.

To return the type of object within the Flash sprite that is currently over the specified stage location, use the following statement:

    hitTest( sprite X, somePointLocation )

In previous versions of Director, there were only three possible return values for this function: `#background`, `#normal`, and `#button`. With the new Flash Asset Xtra, there is a fourth return value possible: `#editText`. This value indicates that an editable text field within the Flash sprite is over the specified location. See `getVariable()`, `setVariable()`, and `hitTest()`.