The ability to create server-side ActionScript provides a familiar way for Flash developers to access ColdFusion resources without having to learn CFML.
Through the Flash Remoting service, Flash developers can leverage their knowledge of ActionScript to access ColdFusion query and HTTP features. The only new things you need to learn to make use of this feature are the use of two new ActionScript functions that let you perform ColdFusion HTTP and query operations, and a few lines of setup code on the client side.
This is a feature that lets you create data-intensive Flash-based applications. Creating ActionScript files that reside on the server helps the business logic part of your application from the user interface.
You can place ActionScript files (*.asr
) on the server anywhere below the web server's root directory. To specify subdirectories of the web root or a virtual directory, use package dot notation. For example, in the following assignment code, the stockquotes.asr file is located in the mydir/stock/ directory:
stockService = gatewayConnnection.getService("mydir.stock.stockquotes", this);
You can also point to virtual mappings, such as, cfsuite.asr.stock.stockquotes
where cfsuite
is a virtual mapping and asr.stock
is subdirectories of that mapping.
Server-side ActionScript lets your ActionScript engineers use their knowledge of ActionScript to write code for the backend of their Flash applications, which can mean more meaningful levels of interactivity for your users. Your Flash applications can share a library of server-side ActionScript functions, which means you can define functions that are specifically tailored to your own business.
You could, for example, create a server-side ActionScript that defines a whole library of SQL query methods. With these query methods defined on the server-side, your Flash designers only have to invoke the specific query function they want to return data to their Flash MX movies. They do not have to write any SQL, and they do not have to create a new query every time they need to retrieve data from a ColdFusion data source. It is a way of creating reusable queries that your entire Flash design team can use.
Coding the ColdFusion query and HTTP operations in ActionScript is very straightforward. The CF.query
and CF.http
functions provide a well-defined interface for building SQL queries and HTTP operations that is based on the legendary simplicity of ColdFusion.
For example, the following is a typical server-side ActionScript function definition that returns query data:
// This function shows a basic CF.query operation using only
// arguments for data source name and for SQL. function basicQuery() { mydata = CF.query({datasource:"customers", sql:"SELECT * FROM myTable"}); return mydata;}