Example Number 2.1

Example Name: HelloUser.fla

Language: ActionScript 1.0

Version: 1.0.1

Code:

#include "NetServices.as"

// Set up variables for the URL and service paths
var myURL = "http://www.flash-remoting.com:8500/flashservices/gateway";
var servicePath = "com.oreilly.frdg.HelloUser";

// Define the custom class SimpleResult 
function SimpleResult() { 
  // Set up onResult and onStatus handlers as methods of the SimpleResult class
  this.onResult = function(myResults){
    results_txt.text = myResults;
  }

  this.onStatus = function(myError){
    results_txt.text = myError.description;
  }

  // Set the system status to be handled by the result status handler as well
  _global.System.onStatus = this.onStatus;
}

// Connection hasn't been initialized; create connection and service objects
if (initialized == null) {
  initialized = true;
  NetServices.setDefaultGatewayURL(myURL);
  var myConnection_conn = NetServices.createGatewayConnection();
  var service = myConnection_conn.getService(servicePath, new SimpleResult());
}

// Set up the callback function to handle mouseclick

Download code text

Download chapter example files