Using NetServices
In the examples in the preceding chapters, the NetServices.as file was included to allow you to use two methods of the NetServices class: createGatewayConnection( ) and setDefaultGateway( ).
There is also a NetServices.getVersion( ) method, which returns the current version of the NetServices class. You can check the version number to maintain backward compatibility if future versions of the NetServices class contain new functionality. Several other methods are used internally as well.
The NetServices class also gives you an interface to the NetConnection class and enhances the NetConnection class to include several new methods:
getService(
remoteMethod,responderObject[,arg1,arg2,...])setCredentials(
username,password)RequestPersistentHeader( )
ReplaceGatewayUrl(
url)
The first two methods should be accessed through the connection that you set up with the createGatewayConnection( ) method. The last two methods are reserved for future use by the Flash Remoting gateway.
Establishing the Gateway Connection
Calling the NetServices.createGatewayConnection( ) method initializes a NetConnection object and returns that object to the Flash movie. The new NetConnection object can be used to connect to the Flash Remoting gateway on the server.
Here, a hardcoded URL for the gateway is passed as an argument to createGatewayConnection( ):
var myURL = "http://localhost/flashservices/gateway"; var myConnection_conn = NetServices.createGatewayConnection(myURL);
Alternatively, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access