Introduction to Network-Aware Communications

     

Introduction to Network-Aware Communications

Flash offers six types of network-aware communication. In most cases, when you're communicating with a server, the same class permits two-way communication, both into and out of your movie. You can use

  • MovieClip methods , such as loadMovie and loadMovieNum (for FP6), or the MovieClipLoader class (for FP7) to load SWF or JPEG files.

    For more on loading SWF or JPEG files, see "Working with Movie Clips," page 517 , in Chapter 20, "Basic ActionScript."


  • The LoadVars class, or its predecessor LoadVariables() , to transfer simple text files or data from an HTML page.

  • The src and movie parameters of both the OBJECT and EMBED tags (in the HTML file) to embed short pieces of text data on an HTML Page.

  • The XML class to transfer structured information formatted in XML (Extensible Markup Language).

  • The NetConnection and NetStream classes to load .flv video/audio files. (This is two-way only when using the Flash Communication Server.)

  • Dynamic data, using Web Services or Flash Remoting, both covered in Chapter 23, "Using Flash for Dynamic Data," page 661.

In the all these cases except the last, the server, if there is one, is a Web server, and the basic communication protocol is typically HTTP. In the case of NetConnection and NetStream , the server, if there is one, is the Flash Communication Server (FCS), and the communication protocol is Macromedia's proprietary RTMP (Real-Time Messaging Protocol).

graphics/new_icon.jpg

Flash MX 2004 brings three new developments in the area of network-aware external communications:


  • Faster XML parsing (decoding or reading). Thank you, Macromedia!

  • The ability to use NetConnection and NetStream to load external .flv files without FCS.

    FLV files are introduced in "A Tale of Two Versions," page 324 , in Chapter 14, "What's New in Flash MX 2004?".


  • New addRequestHeader() methods for the LoadVars class and the XML class. These methods enable you to add or change HTTP request headers . These headers include widely-used standard headers that give the server a variety of information, such as what MIME content types (for example, text, video, audio) or character set the browser prefers or expects; special-purpose headers such as the SOAPAction header that indicates the intent of a SOAP HTTP request; and custom headers that you define yourself.

MIME Types

Browsers and Web servers classify transferred and stored content according to its MIME type. For instance, data-handling applications usually have to specify the MIME type application/x-www-form-urlencoded when sending data to Flash, or Flash can't use the data.


The use of application/x-www-form-urlencoded is demonstrated later in this chapter, under "Loading Dynamic Data with LoadVars," page 627 .


The addRequestHeader() methods are covered at the end of this chapter, under "Customizing HTTP Headers with addRequestHeader()," page 646 .




Using Macromedia Studio MX 2004
Special Edition Using Macromedia Studio MX 2004
ISBN: 0789730421
EAN: 2147483647
Year: N/A
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net