loadVariables(name[,variables])
Top  Previous  Next


SWiSH Player Support
SWF4 or later - Supported Internally

Syntax
spritename.loadVariables ("url" [, variables])

Arguments
spritename: Name of the Sprite / Movie Clip that the variables are loaded.

url: An absolute or relative URL where the variables are located. If you access the Movie using a Web browser, the host for the URL must be in the same subdomain as the Movie itself.

variables: An optional parameter specifying an HTTP method for sending variables. The parameter must be the string GET or POST. If there are no variables to be sent, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for long strings of variables.

Returns
Nothing.

Description
Action and Sprite Method: Reads data from an external file, such as a text file or text generated by a CGI script, Active Server Pages (ASP), or PHP, or Perl script, and sets the values for variables in a Flash Player level or a target Movie Clip. This Action can also be used to update variables in the active Movie with new values.

The text at the specified URL must be in the standard MIME format application/x-www-form-urlencoded (a standard format used by CGI scripts). The Movie and the variables to be loaded must reside at the same subdomain.

Any number of variables can be specified. For example, the phrase below defines several variables:
name=dude&address=home&city=Sydney

When you use the loadVariables Action, you must specify a Sprite / Movie Clip target into which the variables will load.

Sample
The project contains a Sprite named datetime. The datetime Sprite contains two Dynamic Text elements named date and time. The onLoad() Event is for the datetime Sprite.
The referenced URL returns a string
date=dd-mmmm-yyyy&time=hh:mm

The URL is available on our Web site for development / testing purposes.

onLoad () {
    this.date = "date";
    this.time = "time";
    this.loadVariables("http://www.swishzone.com/script_samples/date.php",'GET');
}


Note: The above script must be tested using the test in player or test in browser feature. loadVariables / loadMovies functions cannot be debugged using standard debugging features

The date.php Web page contains the following script:
<?php
   // example script that returns date and time. 

   // demonstrates use of load variable function.

   echo "date=";
   print (date ("d-M-Y"));
   echo "&time=";
   print (date ("H:i"));
?>


See also
loadMovie loadMovieNum ,unloadMovie ,unloadMovieNum ,loadVariables and loadVariablesNum.