User Guide

Table Of Contents
820 Chapter 33: Using the Flash Remoting Service
utils.UIComponents",
null,
null );
// Call the service sayHello() method
var pc:PendingCall = javaService.sayHello();
// Tell the service what methods handle result and fault conditions
pc.responder = new RelayResponder( this, "sayHello_Result",
"sayHello_Fault" );
function sayHello_Result(re:ResultEvent)
{
// Display successful result
trace("Result is: " + re.result);
}
function sayHello_Fault(fe:FaultEvent)
{
// Display fault returned from service
trace("Error is: " + fe.fault.description);
}
Note: For more information about using Java objects with ColdFusion, see Chapter 37, “Using Java
objects,” on page 928.
Handling errors with ColdFusion and Flash
To help with debugging, use the cftry and cfcatch tags in your ColdFusion page or component
to return error messages to the Flash Player. For example, the ColdFusion page, causeError.cfm,
contains the code:
<cftry>
<cfset dev = Val(0)>
<cfset Flash.Result = (1 / dev)>
<cfcatch type = "any">
<cfthrow message = "An error occurred in this service: #cfcatch.message#">
</cfcatch>
</cftry>
The second cfset tag in this example fails because it tries to divide by zero (0). The message
attribute of the
cfthrow tag describes the error; ColdFusion returns this attribute to the Flash
application.
To handle the error in your Flash application, create a fault handler similar to
causeError_Fault
in the following example:
import mx.remoting.*;
import mx.services.Log;
import mx.rpc.*;
// Connect to service and create service object
var CFMService:Service = new Service(
"http://localhost/flashservices/gateway",
null,
"helloExamples",
null,