
Chapter 586
You’ll place the FLA and ASC files in your application directory, and place in that same directory
the netservices.asc file that enables NetServices. You’ll place the CFC or CFM file in the default
directory where you deploy your other ColdFusion script files.
Finally, you’ll test your movie by publishing the SWF file and running it. Make sure the Flash
Communication Server and the ColdFusion MX server are running before you attempt to test
your sample.
Sample 1: Simple Remoting
In this sample, the client application requests some calculations to be done on the application
server and the results to be returned in the string format. The client invokes calls to the Flash
Communication Server. The Flash Communication Server, in turn, acts as a client of the Flash
Remoting service—here, a CFC script—to request that the work be done by the back-end server
and the results returned.
About the sample
When the user clicks the Run Test button, the screen is updated with a message from the server, a
Boolean value, an array of months, and the result of an addition operation.
Re-creating the sample
The doc_remoting.fla file provides the user interface for testing connectivity between the client,
the Flash Communication Server, and the ColdFusion MX server. The main.asc file accepts the
connection from the client, and in turn, connects to ColdFusion using Flash Remoting. The
simple.cfc file contains the scripts for getting a Boolean value, an array, and a sum.
See “Creating your working environment” on page 31 before you start to re-create the sample.
To create the user interface for this sample:
1 From the toolbox, select the Text tool and draw a dynamic text box. In the Property inspector
(Window > Properties), select Dynamic Text for the type of text box, and give it the instance
name
ResultBox.
2 To add the button for running the tests, open the Components panel (Window >
Components) and drag a push button onto the Stage. In the Property inspector, give it the
instance name
Run_btn, the label Run Tests, and the click handler runTests.
3 Create a directory named doc_remoting in your flashcom application directory, and save the
file as doc_remoting.fla in this directory.
To write the client-side ActionScript for this sample:
1 Add the following debug code to trace all the status information coming back from the Flash
Communication Server.
// Trace all the status information.
function traceStatus(info) {
trace("Level: " + info.level + " Code: " + info.code);
}
// Create onStatus prototypes for the objects that
// will return status.
NetConnection.prototype.onStatus = traceStatus;
NetStream.prototype.onStatus = traceStatus;
SharedObject.prototype.onStatus = traceStatus;
Commentaires sur ces manuels