MACROMEDIA FLASH COMMUNICATION SERVER MX-SERVER-SIDE COMMUNICATION ACTIONSCRIPT DICTIONARY Spécifications Page 165

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 369
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 164
Application Server Connectivity 87
2 Create the event handler for the Run_btn button. Notice the call to runTests. This invokes
the function you’ll define later in the server-side code. The second parameter,
new Result(),
provides the functionality for receiving the results of the call to runTests.
// Run the simple remoting tests.
function runTests() {
// Get the return value from the Flash Communication Server and
// display it in the ResultBox. In this sample, the server
// is returning the string "Ran the service on the server".
function Result() {
this.onResult = function(str) {
_root.ResultBox.text = str;
}
}
// Call the "runTests" function on the Flash Communication Server,
// and pass in an instance of the Result function to receive
// the return value from the server.
main_nc.call("runTests", new Result());
}
3
Create a new network connection and connect to the application.
// Create a new connection and connect to the application
// instance on the Flash Communication Server.
main_nc = new NetConnection();
main_nc.connect("rtmp:/doc_remoting/room_01");
4
Provide a handler function that the Flash Communication Server can call to return the results
of the tests.
// Handle the server’s update of ResultBox with
// the result of each test.
NetConnection.prototype.postResults = function(result) {
_root.ResultBox.text += "\n" + result;
}
To write the server-side ActionScript for this sample:
1 Create a new file using your server-side ActionScript editor, and load the netservices.asc file to
enable Flash Remoting through the Flash Communication Server.
load("netservices.asc");
2
In the onAppStart function, define the location of the Flash Remoting service, and connect to
it.
application.onAppStart = function() {
trace("***** on app start");
// Set the default gateway URL
NetServices.setDefaultGatewayUrl("http://localhost:8500/flashservices/
gateway");
// Connect to the gateway
this.gatewayConnnection = NetServices.createGatewayConnection();
}
Vue de la page 164
1 2 ... 160 161 162 163 164 165 166 167 168 169 170 ... 368 369

Commentaires sur ces manuels

Pas de commentaire