64
Chapter 4: Using Flash Remoting Data in ActionScript
The following figure shows this data conversion:
A two-step conversion process enables Flash Remoting to use a system-neutral, efficient
representation for the data it transmits. This way, you can create a Flash application that can work
with multiple application servers.
Flash Remoting performs all data conversions automatically. In most cases, the conversion is
straightforward; you simply pass the ActionScript data as arguments to a remote service, and
process or display the returned data in your callback functions. In a few cases, you must
understand data type conversion considerations to ensure correct application behavior. This
chapter includes information about these considerations.
Understanding Action Message Format
To send and receive messages from remote services, Flash Remoting uses Action Message Format
(AMF), a binary message format designed for the ActionScript object model. Using AMF, Flash
Remoting encodes data types back and forth between the Flash application and the remote service
over HTTP. Modeled on the Simple Object Access Protocol (SOAP), AMF uses a packet format
to relay information. An AMF packet consists of the following parts:
•
Packet header that contains AMF version information
•
Context header count
•
Array of context headers that contain information describing the context in which individual
AMF messages should be processed
•
Message count
•
Array of messages
Server function requests are automatically serialized into AMF format. On the server, Flash
Remoting deserializes the incoming AMF messages. When the server-side processing finishes, the
results are serialized to AMF and sent back to the Flash application. The format of the
server-generated AMF message is identical to the client-generated packet. The body of the
individual AMF message contains the error or response object, which is expressed as an
ActionScript object. For more information about error and response objects, see
Chapter 2,
“Using Flash Remoting ActionScript,” on page 29
.