In this section, you build a simple Flash application that uses Flash Remoting MX to connect to four different remote services, including a ColdFusion page, a JavaBean, an ASPX page, and a web service. You will see that Flash applications require minimal changes to call different remote services.
To build the Hello World application, see the following sections:
Flash Remoting MX supports Java, ASP.NET, and ColdFusion-based remote services. For a simple Hello World application, the following table lists the application server code by platform and where to save the file to make it available to Flash Remoting MX:
For more information about application server-specific documentation, see the following chapters:
To build a Flash application that uses Flash Remoting MX, you write ActionScript in the Flash MX authoring environment that connects to the remote service and calls a service function. For more information on building Flash applications that use Flash Remoting MX, see Chapter 2, "Using Flash Remoting Components in ActionScript".
//imports the NetServices ActionScript file
#include "NetServices.as"
//if statement creates the connection to the remote service and creates a service object
if (inited == null)
{
inited = true;
NetServices.setDefaultGatewayURL("gatewayURL");
serviceConnection = NetServices.createGatewayConnection();
serviceObject = serviceConnection.getService("serviceName", this);
}
//function executes when the user clicks the button
function button_Clicked()
{
//service function call to the remote service
serviceObject.serviceFunctionName();
}
//if the service function is successful, the _Result function of the same name executes
function serviceFunctionName_Result(result)
{
messageDisplay.text = result;
}
//if the service function is unsucessful, the _Status function of the same name executes
function serviceFunctionName_Status(result)
{
messageDisplay.text = error.description;
}
In the code, the ActionScript creates a reference to the remote service using the NetServices functions setDefaultGateway, createGatewayConnection, and getService. You specify the following variables:
serviceFunctionName_Result or serviceFunctionName_Status functions. If the service function call succeeds, the _Result function executes. If the service function fails, the _Status function executes.For more information about connecting to remote services and handling results, see Chapter 2, "Using Flash Remoting Components in ActionScript".
Using the previous ActionScript as a template, the following table lists the values for service name and service function variables:
For more information about application server-specific service name and service function names, see the following chapters:
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flashremoting/mx/Using_Flash_Remoting_MX/intro4.htm
Comments
J___ said on Jan 10, 2004 at 7:44 PM :