View comments | RSS feed

Using HTTP to connect to server-side scripts

The loadVariables function, loadVariablesNum function, getURL function, loadMovie function, loadMovieNum function functions and the loadVariables (MovieClip.loadVariables method), loadMovie (MovieClip.loadMovie method), and getURL (MovieClip.getURL method) methods can communicate with server-side scripts using HTTP or HTTPS protocols.These functions and methods 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 want 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 the following example:

this.createEmptyMovieClip("highscore_mc", 10);
loadVariables("http://www.helpexamples.com/flash/highscore.php", highscore_mc, "GET");

This example loads variables from the ColdFusion script called high_score.cfm 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 CFM and 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 (+) sign. For example, the following phrase defines several variables:

highScore1=54000&playerName1=RGoulet&highScore2=53455&playerName2=
WNewton&highScore3=42885&playerName3=TJones

NOTE

 

You might need to URL-encode certain characters, such as the plus (+) sign or ampersand (&) characters. For more information, see www.adobe.com/go/tn_14143.

For more information, see the following topic: Using the LoadVars class. Also, see loadVariables function, getURL function, loadMovie function, and the LoadVars entry in the ActionScript 2.0 Language Reference.


Flash CS3


Comments


jmathai said on Oct 2, 2007 at 2:51 PM :
Flash CS3 on Windows and Mac fails to pass along any cookies with requests (LoadVars, LoadMovie, etc). Flash 8 on Windows would send cookies from Internet Explorer for a given domain.

This makes it next to impossible to debug swf files that pull dynamic data from a remote server which requires a cookie for authentication. Flashbug is the next best option but is still much less efficient than being able to run Test Movie.

Anyone else run into this problem or have a fix?
jmathai said on Oct 3, 2007 at 11:44 AM :
I failed to mention that the problem stated above is from inside the Flash IDE when running "Test Movie". The exported SWF works fine through the browser. But I am talking in terms of debugging directly from inside of Flash's IDE.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001050.html