
This is the Title of the Book, eMatter Edition
Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
Hello World
|
25
SSAS can be consumed by Flash via Flash Remoting only and cannot be used to cre-
ate other types of output such as HTML.
The SSAS mechanism of ColdFusion MX and JRun 4 is actually a server-side imple-
mentation of the Rhino JavaScript parser, with some server-specific objects and
methods added that allow the developer access to the functionality of
<cfquery> and
<cfhttp> tags of ColdFusion (found in the ActionScript CF object). Methods of the
CF object can be accessed as
CF.methodName( ). You can find a complete discussion of
SSAS in Chapter 6. See http://www.mozilla.org/rhino/ for details on the Rhino project.
To implement the Hello World example in SSAS, create a plain text file named
HelloWorld.asr using any text editor, and place it into the following directory, where
webroot is the root of your web server:
webroot/com/oreilly/frdg/
The code in an SSAS (.asr) file is not compiled or encrypted. If a user
browses to an .asr file, the browser displays the code as plain text
unless you take steps to prevent it at the web server level. You should
turn off read permissions for .asr files in your web server or keep the
files in a secured directory.
Since ColdFusion can process CFCs, ColdFusion pages, and SSAS files, you need to
make sure there are no name conflicts. If you created the ColdFusion component
example file earlier, rename HelloWorld.cfc to SomethingElse.cfc to ensure that the
SSAS (.asr) file, and not the ColdFusion file, is processed. You may also need to
restart the ColdFusion MX server, as the .cfc file may have been cached. The exact
order in which services are located varies with the application server on which the
Flash Remoting gateway is installed. See the appropriate server chapters later in the
book for details.
Example 1-3 shows the code that should be added to HelloWorld.asr; it creates a
simple function called sayHello( ) that returns a string to the client.
Save the file in plain text format and switch back to Flash. Test the Flash movie and
you should see the output from the SSAS function.
If you get an error saying that the service cannot be found, check the service path,
and make sure that there are no syntax errors in the .asr file.
Example 1-3. Server-Side ActionScript code for HelloWorld.asr
function sayHello ( ) {
return "Hello World from Server-Side ActionScript";
}
Kommentare zu diesen Handbüchern