User Guide

70 Chapter 3: Working with External Data
The LoadVars class was introduced in Flash Player 6 to provide a cleaner, more object-oriented
interface for the common task of exchanging CGI data with a web server. Advantages of the
LoadVars class include the following:
You dont need to create container movie clips for holding data or clutter existing movie clips
with variables specific to client/server communication.
The class interface is similar to the XML object, which provides some consistency in
ActionScript. It uses the methods
load(), send(), and sendAndLoad() to initiate
communication with a server. The main difference between the LoadVars and XML classes is
that the LoadVars data is a property of the LoadVars object, rather than an XML Document
Object Model (DOM) tree stored in the XML object.
The class interface is more straightforward—with methods named load, send,
sendAndLoad—than the older loadVariables interface.
You can get additional information about the communication, using the getBytesLoaded and
getBytesTotal methods
You can get progress information about the download of your data (although you cant access
the data until it is fully downloaded).
The callback interface is through ActionScript methods (onLoad) instead of the obsolete,
deprecated
onClipEvent (data) approach required for loadVariables.
There are error notifications.
You can add custom HTTP request headers.
You must create a LoadVars object to call its methods. This object is a container to hold the
loaded data.
For more information, see the LoadVars class entry.
About XML
Extensible Markup Language (XML) is becoming the standard for exchanging structured data in
Internet applications. You can integrate data in Flash with servers that use XML technology to
build sophisticated applications, such as chat or brokerage systems.
In XML, as with HTML, you use tags to specify, or mark up, a body of text. In HTML, you use
predefined tags to indicate how text should appear in a web browser (for example, the
<b> tag
indicates that text should be bold). In XML, you define tags that identify the type of a piece of
data (for example,
<password>VerySecret</password>). XML separates the structure of the
information from the way it appears, so the same XML document can be used and reused in
different environments.
Every XML tag is called a node, or an element. Each node has a type (1, which indicates an XML
element, or 3, which indicates a text node), and elements might also have attributes. A node
nested in a node is called a child node. This hierarchical tree structure of nodes is called the XML
DOM—much like the JavaScript DOM, which is the structure of elements in a web browser.