Browse DevX
Sign up for e-mail newsletters from DevX


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

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




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Flash Remoting Gateway
The Flash Remoting gateway is a server-side object, installed into either a Java (including ColdFusion) or .NET server. In the Java world, the gateway is actually a servlet, while in .NET it is an .aspx file. The gateway is responsible for brokering requests between Flash and the server as well as translating between Flash objects and the native objects for the server on which it is running.

The Flash Remoting gateway is built into ColdFusion, JRun, and Flex servers (all Macromedia products) and is available for purchase from Macromedia for .NET or other Java servers.

Figure 1. Opening the Remoting Libraries: The Remoting Libraries can be accessed through the Common Libraries menu.
ActionScript Messaging Format (AMF)
All communications between the Flash client and the gateway are done using AMF. AMF is like a binary version of SOAP, allowing for smaller data sets to be transferred between the client and server. One key difference between AMF and SOAP is that the data is describing objects specifically for Flash, as opposed to the generic "platform agnostic" descriptions that would actually occur with SOAP. This works, as the Flash Remoting gateway very efficiently translates Flash objects into those usable in .NET or Java.

Flash Remoting Components
To allow a Flash application to use Remoting, the Flash Remoting components need to be compiled into the application. These components are available free and can be downloaded from Macromedia. Macromedia recently rewrote these components, so they can now be used more easily, and directly mirror the other data components, such as the WebServiceConnector and XMLConnector components.

Once these components are installed in Flash Studio, they can be dragged into a Flash movie and used like any other component.

The NetConnection Debugger
Among the things installed with the Flash Remoting Components is the NetConnection Debugger. This debugger allows developers to see the full details of all data sent between the client and server. This can save a great deal of time when troubleshooting dynamic applications, as developers do not need to guess at the content of the data being sent back and forth, nor do they need to write their own debugging code, as they would with Web services.

To use the NetConnection debugger, the debugging classes need to be compiled into the libraries and the debugger needs to be initialized. Both tasks are very easy to do. To include the Remoting Debug Classes, choose Window > Other Panels > Common Libraries > Remoting from the top menu, as shown in Figure 1.

Figure 2. The NetConnectionDebugger Panel: The NetConnectionDebugger will show both parameters sent from Flash to the server as well as the details of the data received.
Next, drag the RemotingDebugClasses symbol from the Remoting library into the library for your application. Once the class is available, it needs to be initialized through code. You can do this by opening the actions panel and typing:

import mx.remoting.debug.NetDebug; NetDebug.initialize();

Be aware, it's always a best practice to remove this debugging framework before going to production; the NetConnectionDebugger can expose more data to end users than most developers would prefer. All that is needed to remove the debugging is to simply delete the RemotingDebugClasses symbol from the library.

Before testing the movie, open the NetConnectionDebugger panel. This can found at Window > Other Panels > NetConnectionDebugger. With the debugger initialized and open, any Remoting traffic between the client and server will show in the panel, as seen in Figure 2.

Comment and Contribute






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



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