Flash Remoting Code
The ActionScript code used to contact the remote services is contained in several files described in the following sections. One caveat when working with Flash Remoting is that the remote calls are asynchronous. This creates problems when you’re trying to separate the logic in your applications, as discussed in Chapter 12. In our application, we decided to keep the logic simple by implementing the UI logic from within our responder objects. In other words, when a remote call returns a result, the responder object takes care of the details of updating the display.
RemotingInit.as
The RemotingInit.as file contains all of the Flash Remoting initialization code needed for the movie. The code is identical to the code you’ve seen throughout the book, but in this case we are creating three distinct service objects: one for the UserService, one for the ScriptService, and one for the SiteService. The code is shown in Example 14-7.
// Remoting initialization if (initialized == null) { initialized = true; NetServices.setDefaultGatewayUrl("http://localhost/flashservices/gateway"); my_conn = NetServices.createGatewayConnection( ); // Create the service objects UserService = my_conn.getService( "com.oreilly.frdg.ScriptRepository.UserService"); ScriptService = my_conn.getService( "com.oreilly.frdg.ScriptRepository.ScriptService"); SiteService = my_conn.getService( "com.oreilly.frdg.ScriptRepository.SiteService"); ...
Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.