Sending and loading variables to and from a remote source
69
Using HTTP to connect to server-side scripts
The
getURL()
function and the
MovieClip.loadVariables()
,
MovieClip.loadMovie()
, and
MovieClip.getURL()
methods can communicate with server-side scripts using HTTP or
HTTPS protocols. When used as a method of the MovieClip object,
getURL()
sends all the
variables of the specified movie clip; each function (or method) handles its response as follows:
•
The
getURL()
function returns any information to a browser window, not to Flash Player.
•
The
loadVariables()
methods loads variables into Flash Player.
•
The
loadMovie()
methods loads a SWF file into a specified movie clip in Flash Player.
When you use
loadVariables()
,
getURL()
, or
loadMovie()
, you can specify
several parameters:
•
URL
is the file in which the remote variables reside.
•
Location
is the target in the SWF file that receives the variables. (The
getURL()
function does
not take this parameter.)
•
Variables
sets the HTTP method, either
GET
(appends the variables to the end of the URL)
or
POST (
sends the variables in a separate HTTP header), by which the variables are sent.
When this parameter is omitted, Flash Player defaults to
GET
, but no variables are sent.
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:
loadVariables("http://www.mySite.com/scripts/high_score.cfm", scoreClip, 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 (
+
). 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 (+) or ampersand (&)
characters. For more information, see
www.macromedia.com/support/flash/ts/documents/
url_encoding.htm
.
For more information, see
getURL()
, the
LoadVars class
entry, and
“Using the LoadVars class”
on page 69
.
Using the LoadVars class
If you are publishing to Flash Player 6 or later and want more flexibility than
loadVariables()
offers, you can use the LoadVars class instead to transfer variables between a SWF file and a server.
Содержание FLEX-FLEX ACTIONSCRIPT LANGUAGE
Страница 1: ...Flex ActionScript Language Reference...
Страница 8: ......
Страница 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Страница 76: ......
Страница 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Страница 135: ...case 135 See also break default strict equality switch...
Страница 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Страница 229: ...while 229 i 3 The following result is written to the log file 0 3 6 9 12 15 18 See also do while continue for for in...
Страница 808: ...808 Chapter 7 ActionScript for Flash...
Страница 810: ...810 Appendix A Deprecated Flash 4 operators...
Страница 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Страница 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Страница 822: ...822 Index...