1.7 Workflow Example

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:

  1. Using the NetServices API within Flash, developer-written code makes a call for a remote service.

  2. The NetServices library passes the remote service call, along with any arguments, to the NetConnection object within the Flash Player.

  3. The NetConnection object serializes the request into AMF and sends it to server as an HTTP binary POST.

  4. The Flash Remoting gateway on the server receives the request, deserializes it and determines the server-side service to which to pass the request.

  5. The Flash Remoting gateway on the server invokes the server-side service, passing any arguments sent along with the request from the Flash Player.

  6. 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.

  7. 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.

  8. 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.

    Part III: Advanced Flash Remoting