User Guide

275
CHAPTER 11
Working with External Data
In Macromedia Flash MX 2004 and Macromedia Flash MX Professional 2004, you can use
ActionScript to load data from external sources into a SWF file. You can also send data from a
SWF file for processing by an application server (such as Macromedia ColdFusion MX or
Macromedia JRun) or another type of server-side script, such as PHP or Perl. Macromedia Flash
Player can send and load data over HTTP or HTTPS or load from a local text file. You can also
create persistent TCP/IP socket connections for applications that require low latency—for
example, chat applications or stock quote services.
Data that you load into or send from a SWF file can be formatted as XML (Extensible Markup
Language) or as name-value pairs.
Flash Player can also send data to and receive data from its host environment—a web browser, for
example—or another instance of Flash Player on the same computer or web page.
By default, a SWF file can access only data that resides in exactly the same domain (for example,
www.macromedia.com). (For more information, see “Flash Player security features
on page 288.)
Sending and loading variables to and from a remote source
A SWF file is a window for capturing and displaying information, much like an HTML page.
However, SWF files can stay loaded in the browser and continuously update with new
information without having to reload the entire page. Using ActionScript functions and methods,
you can send information to and receive information from server-side scripts, and receive
information from text files and XML files.
In addition, server-side scripts can request specific information from a database and relay it to a
SWF file. Server-side scripts can be written in different languages: some of the most common are
CFML, Perl, ASP (Microsoft Active Server Pages), and PHP. By storing information in a database
and retrieving it, you can create dynamic and personalized content for your SWF file. For
example, you could create a message board, personal profiles for users, or a shopping cart that
keeps track of a user’s purchases.
Several ActionScript functions and methods let you pass information into and out of a SWF file.
Each function or method uses a protocol to transfer information and requires information to be
formatted in a certain way.