Sending and loading variables to and from a remote source
179
For more information, see
“Using the XML class” on page 181
and
“Using the XMLSocket class”
on page 184
.
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:
•
getURL()
returns any information to a browser window, not to Flash Player.
•
loadVariables()
loads variables into a specified Timeline or level in Flash Player.
•
loadMovie()
loads a SWF file into a specified level or 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 level or target in the SWF file that receives the variables. (The
getURL()
function does not take this parameter.)
For more information about levels and targets, see “About multiple Timelines and levels” in
Using Flash Help.
•
Variables
sets the HTTP method, either
GET
or
POST
, by which the variables will be sent.
When omitted, Flash Player defaults to
GET
, but no variables are sent.
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=good&highScore2=53455&playerName2=
bonehelmet&highScore3=42885&playerName3=soda+pop
For more information, see
loadVariables()
on page 422
,
getURL()
on page 394
,
loadMovie()
on page 420
, and the
LoadVars class
entry in
Chapter 12, “ActionScript
Dictionary,” on page 205
.
Содержание FLASH MX 2004 - ACTIONSCRIPT
Страница 1: ...ActionScript Reference Guide...
Страница 8: ...8 Contents...
Страница 12: ......
Страница 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Страница 54: ...54 Chapter 2 ActionScript Basics...
Страница 80: ...80 Chapter 3 Writing and Debugging Scripts...
Страница 82: ......
Страница 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Страница 112: ......
Страница 120: ...120 Chapter 6 Using the Built In Classes...
Страница 176: ......
Страница 192: ...192 Chapter 10 Working with External Data...
Страница 202: ...202 Chapter 11 Working with External Media...
Страница 204: ......
Страница 782: ...782 Chapter 12 ActionScript Dictionary...
Страница 793: ...Other keys 793 221 222 Key Key code...
Страница 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Страница 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Страница 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Страница 816: ...816 Index...