
This is the Title of the Book, eMatter Edition
Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
Hello World
|
23
Server-Side Code
In the next section, you’ll create the remote service required by this simple Flash
movie. Once you have created the remote service, you can test the Flash movie using
Control
➝ Test Movie. You should get the following output displayed in the Output
window:
Data received from Server : Hello World from servertype
If you do not get this result:
• Set the Output window to verbose mode (Window
➝ Output ➝ Options ➝
Debug Level ➝ Verbose).
• Make sure that the server where the Flash Remoting gateway is installed is run-
ning and accessible.
• Make sure that there are no syntax errors in your client-side ActionScript code or
server-side code.
ColdFusion MX
For the ColdFusion MX example, we will implement the remote service as a Cold-
Fusion Component (CFC). CFCs are new to ColdFusion MX and provide an object-
based approach to ColdFusion development. They are ideally suited to Flash
Remoting. CFCs are discussed in depth in Chapter 5.
Create a file named HelloWorld.cfc and place it into the following directory, where
webroot is the root of your web server and com\oreilly\frdg\ matches the service path
specified by the initial portion of the
myServicePath variable in Example 1-1:
webroot\com\oreilly\frdg
Example 1-2 shows the code that must be added to your HelloWorld.cfc component:
This is a simple component that contains one function, sayHello( ), which returns a
string. Notice that we set the
access to "remote", which is necessary to allow the
component to be called remotely, either by Flash or as a web service.
Save the component. If you have access to the ColdFusion administrative interface
(which you should if you have a local installation) browse to it through your browser
with the following URL:
http://
yourservername/com/oreilly/frdg/HelloWorld.cfc/
Example 1-2. ColdFusion code for HelloWorld.cfc
<cfcomponent>
<cffunction name="sayHello" access="remote" returntype="string">
<cfreturn "Hello World from ColdFusion Component" />
</cffunction>
</cfcomponent>
Kommentare zu diesen Handbüchern