
2003 Macromedia, Inc. 9
Setting the Connection to the Remoting Gateway
8. From the Actions toolbox, expand the Remoting tree view. (If you
don’t see the Remoting tree view, check to be sure you installed the
Flash Remoting Components.)
9. Position your cursor below the included ActionScript files section.
10. Double-click #include NetServices.as and #include NetDebug.as and
#include DataGlue.as to add them to the code. These files provide the
objects to connect to the remote server, debug the connection, and bind
data to your UI components. We’ll do this later.
11. Position your cursor below the run at once commands section at the
bottom of the code window.
12. In the Actions toolbox, drill down to Remoting Æ NetServices Æ
Methods, and double click setDefaultGatewayURL(). This method
identifies the location of the Flash Remoting gateway on a server.
13. Inside the parenthesis, type
“http://localhost/flashremoting/gateway.aspx” for the location of
Flash Remoting handling all remote requests.
14. Create a connection to the remote server called connection using the
NetServices.createGatewayConnection() method:
connection = NetServices.createGatewayConnection();
Invoking a Remote Method
15. Access the remote service RemoteCatalog using its fully-qualified
name, as follows:
Create a variable named catalogService to store the service.
Using the connection object, invoke the getService() method.
This method identifies the remote component to access during
method invocations.
Inside the parenthesis, specify the fully-qualified class name of the
RemoteCatalog class inside quotes (as specified in your CS code):
“samples.remoting.RemoteCatalog”
Use this as the default responder object. It means that the current
Flash movie (RemoteCatalog) will be the object that will receive
the returned data from the remote call:
catalogService =
connection.getService("samples.remoting.RemoteCatalog", this);
Komentarze do niniejszej Instrukcji