13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 42: Basics of networking and<br />

communication<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

Wh<strong>en</strong> you build applications in Flash Player or AIR, you oft<strong>en</strong> need to access resources outside your application. For<br />

example, you might s<strong>en</strong>d a request for an image to an Internet web server and get the image data in return. Or, you<br />

might s<strong>en</strong>d serialized objects back and forth over a socket connection with an application server. The Flash Player and<br />

AIR APIs provide several classes that allow your applications to participate in this exchange. These APIs support IPbased<br />

networking for protocols like UDP, TCP, HTTP, RTMP, and RTMFP.<br />

The following classes can be used to s<strong>en</strong>d and receive data across a network:<br />

Class Supported data formats Protocols Description<br />

Loader SWF, PNG, JPEG, GIF HTTP, HTTPS Loads supported data types and converts the<br />

data into a display object.<br />

URLLoader Any (text, XML, binary,<br />

etc.)<br />

See “Loading display cont<strong>en</strong>t dynamically” on<br />

page 198.<br />

HTTP, HTTPS Loads arbitrary formats of data. Your<br />

application is responsible for interpreting the<br />

data.<br />

FileRefer<strong>en</strong>ce Any HTTP<br />

See “Using the URLLoader class” on page 814<br />

Upload and download files.<br />

NetConnection Video, audio, ActionScript<br />

Message Format (AMF)<br />

HTTP, HTTPS,<br />

RTMP, RTMFP<br />

Oft<strong>en</strong>, wh<strong>en</strong> creating a web application it is helpful to store persist<strong>en</strong>t information about the user’s application state.<br />

HTML pages and applications typically use cookies for this purpose. In Flash Player, you can use the SharedObject<br />

class for the same purpose. See “Shared objects” on page 700. (The SharedObject class can be used in AIR applications,<br />

but there are fewer restrictions wh<strong>en</strong> just saving the data to a regular file.)<br />

Last updated 6/6/2012<br />

See “Using the FileRefer<strong>en</strong>ce class” on<br />

page 652<br />

Connects to video, audio and remote object<br />

streams.<br />

Sound Audio HTTP<br />

See “Working with video” on page 474.<br />

Loads and plays supported audio formats.<br />

XMLSocket XML TCP<br />

See “Loading external sound files” on<br />

page 443.<br />

Exchanges XML messages with an XMLSocket<br />

server.<br />

Socket Any TCP<br />

See “XML sockets” on page 801.<br />

Connects to a TCP socket server.<br />

SecureSocket (AIR) Any TCP with SSLv3<br />

or TLSv1<br />

See “Binary cli<strong>en</strong>t sockets” on page 797.<br />

Connects to a TCP socket server that requires<br />

SSL or TLS security.<br />

ServerSocket (AIR) Any TCP<br />

See “Secure cli<strong>en</strong>t sockets (AIR)” on page 797.<br />

Acts as a server for incoming TCP socket<br />

connections.<br />

DatagramSocket (AIR) Any UDP<br />

See “Server sockets” on page 805.<br />

S<strong>en</strong>ds and receives UDP packets.<br />

See “UDP sockets (AIR)” on page 807<br />

788

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!