Having discussed how the Flash Player and the Flash Remoting gateway communicate, now let's look at what occurs behind the scenes. We will examine each step of the earlier Hello World example. In Example 1-1, a remote service was called from Flash and received a "Hello World" string in response.
Here are the steps that occur:
Using the NetServices API within Flash, developer-written code makes a call for a remote service.
The NetServices library passes the remote service call, along with any arguments, to the NetConnection object within the Flash Player.
The NetConnection object serializes the request into AMF and sends it to server as an HTTP binary POST.
The Flash Remoting gateway on the server receives the request, deserializes it and determines the server-side service to which to pass the request.
The Flash Remoting gateway on the server invokes the server-side service, passing any arguments sent along with the request from the Flash Player.
The Flash Remoting gateway on the server receives any data returned from the service (in this case, the string "Hello World"), serializes it into AMF, and returns it to the client-side Flash Player as an HTTP response.
The Flash Player receives the AMF data from the server and deserializes it into a native ActionScript datatype (in this case a String object). Depending on the data sent back, the deserialization is done within the Flash Player or the NetServices code.
Finally, the string is returned to an ActionScript callback function specified by the developer to receive data loaded from the server.
Although a lot happens when a remote service is called from the Flash Player, most steps are abstracted away from the developer. The developer has only to write the client-side ActionScript that calls the remote service (Step 1) and receive the response from the remote service (Step 8). Of course, someone has to write the code for the remote service itself (Step 5), but that is often done by a different developer or independently of Flash, such as in the case where a Flash front end is being added to an existing web service.