Introduction to Dynamic Data in Flash MX 2004

     

This chapter focuses on using Flash MX 2004 for accessing databases. Although most of the material on Flash in this book is applicable to either the Standard or Professional version, this chapter uses three components available only in Flash MX 2004 Professional: the WebServiceConnector, DataSet, and DataGrid components. Data components such as these make the Professional version of Flash MX 2004 the clear choice for anyone planning to work with databases.

A Flash movie can access a database at runtime and either display the data or use it internally for decision-making. The Flash Player supports two fundamentally different database access technologies:

  • Flash Remoting, which is unchanged from Flash MX and uses Macromedia's proprietary Action Message Format (AMF) communication protocol. AMF is highly efficient and optimized for the Flash client. The Flash client receives replies as ActionScript objects.

  • graphics/new.jpg Web services, based on the WebServiceConnector component, new in Flash MX 2004 Professsional. The WebServiceConnector uses Simple Object Access Protocol (SOAP). SOAP is an open standard, but somewhat verbose, meaning that its packets are large, and therefore data transfer is relatively inefficient. SOAP is not optimized for the Flash client. The Flash client receives replies as XML documents and must transform the XML into ActionScript objects to use the data in the ActionScript environment.

For a brief introduction to dynamic content in Studio MX 2004, see "Dynamic Content," page 20 , in Chapter 2, "Studio MX: a Bird's-Eye View."


Even for the relatively small and simple recordset used as an example in this chapter, and using the local host (the Web server running on the same machine as the Flash client), I find Flash Remoting to be noticeably faster than Web services. When the service is accessed over the network (as in all real-world situations), the speed advantage of Flash Remoting usually becomes much more evident. Flash Remoting is also more mature and therefore tends to be more robust.

SWFs are also substantially smaller with Flash Remoting, perhaps because the Web services approach requires two data components (WebServiceConnector and DataSet) that are not required for Flash Remoting. For example, this chapter features two applications that do exactly the same thing, one with Flash Remoting, the other using Web services. The SWF for Flash Remoting is around 65KB. The SWF for Web services is around 125KB.

From the user 's perspective, the only difference between Flash Remoting and Web services is that the latter is slower. On the other hand, as a developer, you have to consider the fact that Flash Remoting locks you and your client into a Macromedia solution on the server side: You can access data on a server only if the server has the Macromedia Flash Remoting Gateway (FRG) installed. The FRG can be installed in a variety of environments, falling into four major categories, summarized in Table 23.1.

Table 23.1. Major Environments Supporting Flash Remoting Gateway

Environment

Service Implementation

J2EE

Enterprise JavaBeans (EJBs), JavaBeans, Plain Old Java Objects (POJOs), Java Management Extension (JMX) MBeans

.NET services

ASP.NET technologies, ADO.NET data-binding adapters, .NET assemblies (DLLs), .NET Web services

Server pages

Microsoft ASP pages, Java Server Pages (JSP) and Servlets, Macromedia ColdFusion components (CFCs)

XML objects

SOAP-based Web services exposed through WSDL files, org.w3c.dom.Document objects, and other serialized XML objects


NOTE

WSDL is Web Services Description Language, a standard XML-based language for describing Web services.


As you can see from Table 23.1, the FRG offers great flexibility in choosing a server technology. However, sites that you do not control are more likely to make services available as Web services than to implement the FRG. Thus, using the Web services approach on the Flash client gives you access to a wide variety of publicly available services, ranging from information about books and products from Amazon.com to the free translation service from BabelFish.

The ability to access Web services is extremely useful. From a technical perspective, the Web services approach is best suited to applications where the amount of data is small. From a practical perspective, you may have to use it whenever you do not control the server, and thus cannot install the FRG.

For a discussion of Flash Remoting and Web services in the ColdFusion context, see "Using Flash to Access the ColdFusion Server," page 878 , in Chapter 32, "Understanding and Administering ColdFusion."


CAUTION

The same security restrictions that apply to downloading other types of data apply to Flash Remoting and Web services.


For more on security, see "New Security Rules," page 330 , in Chapter 14, "What's New in Flash MX 2004?". Also see crossDomainPolicyFiles.htm and security2004.htm on the CD accompanying this book.


Before you can get hands-on with any of the features discussed in this chapter, you must have access to a server with a service that is implemented using one of the technologies shown in the right column of Table 23.1. In the examples in this chapter, the server is ColdFusion, so the implementation is a CFC. To make the examples in this chapter work on your system as they are shown in this chapter, you need to have ColdFusion up and running, and you need to copy qProducts.cfc from the CD into the //CfusionMX/ wwwroot /greendept folder (creating the greendept folder first, if necessary).

For a discussion of other things you may need to do to have a functional ColdFusion development environment, see "Introducing ColdFusion," page 876 , in Chapter 32.


Chapter 13 of this book ("Developing ColdFusion Applications in Dreamweaver), page 312 , gives instructions for creating several ColdFusion Components (CFCs), one of which I adapt for the examples in this chapter. If you are not familiar with CFCs, I recommend that you read Chapters 13 and 32.


I will assume that you are running the services on your local host (e.g. http://localhost:8500/greendept/myCFC.cfc). Except for security considerations (primarily cross-domain access), putting a service up on the Web after testing it locally is a simple matter of uploading the .cfc file to the ColdFusion server and changing the domain in the URL that is used to access the service (for example, http://www.myDomain.com/greendept/myCFC.cfc ).



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