User Guide
Loading data 477
Loading data
SWF files can load data from servers into ActionScript, and send data from ActionScript to
servers. Loading data is a different kind of operation from loading media, because the loaded
information appears directly in ActionScript, rather than being displayed as media. Generally,
SWF files may load data from their own domains. However, they usually require cross-
domain policy files in order to load data from other domains.
Using URLLoader and URLStream
You can load data, such as an XML file or a text file. The load() methods of the URLLoader
and URLStream classes are governed by cross-domain policy file permissions.
If you use the
load() method to load content from a domain other than that of the SWF file
that is calling the method, Flash Player checks for a cross-domain policy file on the server of
the loaded assets. If there is a cross-domain policy file, and it grants access to the domain of
the loading SWF file, you can load the data.
Connecting to sockets
Cross-domain access to socket and XML socket connections is disabled by default. Also
disabled by default is access to socket connections in the same domain as the SWF file on
ports lower than 1024. You can permit access to these ports by serving a cross-domain policy
file from any of the following locations:
■ The same port as the main socket connection
■ A different port
■ An HTTP server on port 80 in the same domain as the socket server
If you serve the cross-domain policy file from same port as the main socket connection, or in
a different port, you enumerate permitted ports by using a
to-ports attribute in the cross-
domain policy file, as the following example shows:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy
SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<!-- Policy file for xmlsocket://socks.mysite.com -->
<cross-domain-policy>
<allow-access-from domain="*" to-ports="507" />
<allow-access-from domain="*.example.com" to-ports="507,516" />
<allow-access-from domain="*.example.org" to-ports="516-523" />
<allow-access-from domain="adobe.com" to-ports="507,516-523" />
<allow-access-from domain="192.0.34.166" to-ports="*" />
</cross-domain-policy>