Using Flash Remoting with ColdFusion pages
103
The directory name is the service address, and the helloWorld.cfm file is a method of the
helloExamples directory of the Flash Remoting service. The following ActionScript example calls
the helloWorld ColdFusion page:
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
var CFMService:Service = new Service(
"http://localhost:8300/flashservices/gateway",
null,
"helloExamples",
null,
null);
var pc:PendingCall = CFMService.helloWorld();
pc.responder = new RelayResponder(this, "helloWorld_Result",
"helloWorld_Fault");
function helloWorld_Result( re:ResultEvent ):Void {
trace( re.result.HELLOMESSAGE ); // will output "Hello World"
trace( re.result.TIMEVAR ); // will output current date
}
function helloWorld_Fault( fe:FaultEvent ):Void {
}
Within the result handler of the
helloWorld()
method, you access the structure returned by
ColdFusion.
Returning record sets to Flash
A Flash application often calls a ColdFusion page so that the ColdFusion page can access a
database and return a record set to the Flash application. For example, the following ColdFusion
code executes a query and returns the results of the entire query to the Flash application:
<cfquery name="myQuery" datasource="ExampleApps">
SELECT *
FROM tblItems
</cfquery>
<cfset Flash.Result = myQuery>
You can pass parameters from the Flash application to the ColdFusion page to conditionalize the
query. The previous section contained an example that passed a parameter to the
WHERE
clause of
the query, as the following code shows:
<cfquery name="myQuery" datasource="ExampleApps">
SELECT ItemName, ItemDescription, ItemCost
FROM
tblItems
WHERE ItemName=
'#Flash.Params[1]#'
</cfquery>
<cfset Flash.Result = myQuery>
Содержание FLASH REMOTING MX
Страница 1: ...Using Flash Remoting for Flash MX 2004 ActionScript 2 0...
Страница 8: ...8 Contents...
Страница 62: ...62 Chapter 3 Using the RemotingConnector component Flash Professional only...
Страница 142: ...142 Chapter 7 Using Flash Remoting for Java...