166
Appendix A: Using NetServices and Connection Classes
The following example illustrates these steps:
myService.logout();
gatewayConnection.setCredentials("", "");
The technique that you use to authenticate the user and to authorize access on the application
server depends on the application server you are using.
Creating the service object
Before you access a service function, you must use the
getService()
method of the gateway
connection object to create a service object in the Flash client. The
gatewayConnection.getService()
method takes the following two parameters:
•
The service name.
•
Optionally, the name of the Flash responder object that will receive the results. If you omit the
Flash responder, you must specify a Flash responder in each service function call. For more
information on considerations for specifying a Flash responder, see
“Handling results for a
Connection object” on page 167
.
The following example shows the
getService()
method for the
remoteservices
service, which
contains a
helloWorld()
function:
import mx.remoting.NetServices;
import mx.remoting.Connection;
if (inited == null)
{
inited = true;
NetServices.setDefaultGatewayUrl("http://localhost:8300/flashservices/
gateway")
var gatewayConnection:Connection = NetServices.createGatewayConnection();
howdyService =
gatewayConnection.getService("remoteservices", this);
howdyService.helloWorld();
}
function helloWorld_Result(result)
{
// display successful result
messageDisplay.text = result;
}
In this example, you create the
howdyService
Service object.
By specifying
"this"
as the responder object, you specify that the current Flash object is also the
responder that contains the result handling method. It is a common practice to create the service
object and define the result-handler callback routines in a single Flash object.
Содержание FLASH REMOTING MX
Страница 1: ...Using Flash Remoting for Flash MX 2004 ActionScript 2 0...
Страница 8: ...8 Contents...
Страница 62: ...62 Chapter 3 Using the RemotingConnector component Flash Professional only...
Страница 142: ...142 Chapter 7 Using Flash Remoting for Java...