Using HTTP to connect to server-side scripts

The loadVariables(), loadVariablesNum(), getURL(), loadMovie(), and loadMovieNum() functions and the MovieClip.loadVariables(), MovieClip.loadMovie(), and MovieClip.getURL() methods can all communicate with server-side scripts over HTTP or HTTPS protocols. These functions send all the variables from the Timeline to which the function is attached. When used as methods of the MovieClip object, loadVariables(), getURL(), and loadMovie() send all the variables of the specified movie clip; each function (or method) handles its response as follows:

When you use loadVariables(), getURL(), or loadMovie(), you can specify several parameters:

For example, if you wanted to track the high scores for a game, you could store the scores on a server and use loadVariables() to load them into the SWF file each time someone played the game. The function call might look like this:

loadVariables("http://www.mySite.com/scripts/high_score.php", _root.scoreClip, GET);

This loads variables from the PHP script called high_score.php into the movie clip instance scoreClip using the GET HTTP method.

Any variables loaded with the loadVariables() function must be in the standard MIME format application/x-www-form-urlencoded (a standard format used by CGI scripts). The file you specify in the URL parameter of loadVariables() must write out the variable and value pairs in this format so that Flash can read them.This file can specify any number of variables; variable and value pairs must be separated with an ampersand (&), and words within a value must be separated with a plus (+). For example, this phrase defines several variables:

highScore1=54000&playerName1=rockin+good&highScore2=53455&playerName2=bonehelmet&highScore3=42885&playerName3=soda+pop

For more information, see loadVariables(), getURL(), loadMovie(), and LoadVars class.