Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Powering Flash Applications with a Server, Part 2—Flash Remoting : Page 3

When connecting Flash applications to a server, Flash Remoting offers better performance over Web services.


advertisement
Using Flash Remoting
Using the FlashRemotingConnector components is no more difficult than using the WebServiceConnector components as discussed in the first article. To demonstrate this, I'll use the same application from that earlier article and modify it to use Remoting instead of Web services.

Figure 3 shows the application interface, this time with RemotingConnector components in place of the WebServiceConnector components. With ColdFusion as the server, no changes need to be made to the server-side code to switch between Web services and Remoting.

Figure 3. The Interface: The sample application uses a simple interface with two list boxes, three RemotingConnectors, a Button, and two text fields.
For each connector, use the component inspector to set the properties including the gateway address and the object and method names (see Figure 4).



Once the properties are set, all that remains is to trigger the components and handle the results. Again, this is identical to the process used for Web services. Listing 1 shows the full source code for the Remoting version of the sample application, the Radio Free Astoria song requestor module.

Assuming a simple interface (see Figure 2) of two list boxes, a text field, a button, and three RemotingConnector components drawn on the stage in Flash, the ActionScript in Listing 1 defines the corresponding functionality. The handleEvent method routes all the broadcast events to their appropriate handlers.

This code directly mirrors the code from the first article that used Web services (see Listing 2 ), with the only differences being the inclusion of NetDebug initialization at the beginning and the use of RemotingConnectors instead of WebServiceConnectors. The application functions identically, except the data transfer between client and server is significantly faster.

How much faster? In comparing performance of the "Song Requestor" application using Web services (see http://www.devx.com/webdev/Article/21803/0/page/3) to the same application using Flash Remoting in this article, the time between triggering the connection to the server and when usable data was returned is five times longer with Web services. In local testing with Flash Remoting it took an average of 608ms between triggering the getArtists method and when the Artist ListBox was populated. Triggering the same method using Web services took an average of 3182ms before the ListBox was populated. Independent testing of other applications has shown similar results.

Figure 4. Set It Up Right: The component inspector is used to set the URL for the Remoting gateway, as well as to specify the object (servicename) and method (methodname) that will be used.
Benefits of Flash Remoting
Both Web services and Flash Remoting offer developers the opportunity to connect and exchange data with objects on the server. The main difference between the two is that the Flash Remoting server handles the work of translating between Flash data types and those used by the Application Server, while Web services require the Flash Player to handle all the data parsing.

Flash Remoting was introduced with the release of Flash MX, prior to the support for Web services with Flash. At that time, Remoting was the only means available to connect a Flash client to a remote object. With the release of Flash MX 2004 and the support for Web services it brought, many believed that there was no longer a place in Flash applications for Remoting.

In fact, that couldn't be further from the truth. While Web services offer an alternative, Flash Remoting remains the recommended means to connect a Flash client to an application server. The Web services alternative is there for those who do not have access to a Flash Remoting Server, however, those who do have a choice between Flash Remoting and Web services will be rewarded with much greater performance using Remoting.



Jeff Tapper is the Chief Technologist for Tapper.net Consulting. He has been developing Internet-based applications since 1995, for clients including Ben and Jerry's, IBM, Harley Davidson, and American Express. He is certified to teach all of Macromedia's courses on ColdFusion and Flash development. He has worked as author and technical editor for several books, including the recently released "Object Oriented Programming with ActionScript 2.0," and is a frequent speaker at Macromedia development conferences and user groups.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date