User Guide

276 Chapter 11: Working with External Data
The functions and MovieClip methods that use the HTTP or HTTPS protocol to send
information in URL-encoded format are
getURL(), loadVariables(),
loadVariablesNum(), loadMovie(), and loadMovieNum().
The LoadVars methods that use the HTTP or HTTPS protocol to send and load information
in URL-encoded format are
load(), send(), and sendAndLoad().
The methods that use HTTP or HTTPS protocol to send and load information as XML are
XML.send(), XML.load(), and XML.sendAndLoad().
The methods that create and use a TCP/IP socket connection to send and load information as
XML are
XMLSocket.connect() and XMLSocket.send().
For more information, see the following topics:
“Checking for loaded data” on page 276
“Using HTTP to connect to server-side scripts” on page 277
“Using the LoadVars class” on page 278
About XML” on page 280
“Using the XML class” on page 280
“Using the XMLSocket class” on page 284
Checking for loaded data
Each function or method that loads data into a SWF file (except
XMLSocket.send()) is
asynchronous: The results of the action are returned at an indeterminate time.
Before you can use loaded data in a SWF file, you must check to see if it has been loaded. For
example, you cant load variables and manipulate their values in the same script because the data
to manipulate doesnt exist in the file until it is loaded. In the following script, you cannot use the
variable
lastSiteVisited until youre sure that the variable has loaded from the
file
myData.txt. In the file myData.txt, you would have text similar to the following example:
lastSiteVisited=www.macromedia.com
But if you used the following code, you could not trace the data that is loading:
loadVariables("myData.txt", 0);
trace(lastSiteVisited);
Each function or method has a specific technique you can use to check data it has loaded. If you
use
loadVariables() or loadMovie(), you can load information into a movie clip target and
use the
onData handler to execute a script. If you use loadVariables() to load the data, the
onData handler executes when the last variable is loaded. If you use loadMovie() to load the
data, the
onData handler executes each time a fragment of the SWF file is streamed into Flash
Player.
Each function or method has a specific technique you can use to check data it has loaded. If you
use
loadVariables(), you can load information into a movie clip target and use the
MovieClip.onData handler to execute a script; the onData handler executes when the last
variable is loaded.