ColdFusion pages and components can return error information to a Flash application if the ColdFusion code fails. For example, the following Flash application calls a ColdFusion page named causeError.cfm:
#include "NetServices.as"
NetServices.setDefaultGatewayUrl("http://localhost/flashservices/gateway");
gatewayConnection = NetServices.createGatewayConnection();
CFMService = gatewayConnection.getService("errorExample", this);
CFMService.causeError();
To help with debugging your ColdFusion code, use the cftry and cfcatch tags in your ColdFusion page or component to catch errors and return helpful error messages about the errors to the Flash application. For example, the ColdFusion page causeError.cfm contains the following 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>
In this example, the second cfset tag fails because it causes a divide-by-zero error. The message attribute of the cfthrow tag describes the error and is returned to the Flash application by ColdFusion. For more information on using the cftry and cfcatch tags, see Developing ColdFusion MX Applications with CFML.
To handle the error in your Flash application, you create a Status handler for the causeError method, as follows:
function causeError_Status ( error )
{
resultBox.text = error.description;
}
In this example, resultBox is a Flash text box that displays the error message created by the cfthrow tag.
For more information on handling errors, see Chapter 2, "Using Flash Remoting Components in ActionScript".
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/usingFRCF7.htm