Using Flash Remoting with server-side ActionScript
The ability to create server-side ActionScript provides a familiar way for Flash developers to access
ColdFusion query and HTTP features without learning CFML. Identify the ActionScript files
(with the .asr extension) that you want to call from the Flash application and place them on the
server, anywhere under 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 in the mydir\stock\ directory:
var stockService:Service =
gatewayConnnection.getService("mydir.stock.stockquotes", this);
You can also point to virtual mappings, such as
is a virtual mapping and
cfsuite
and
functions give you a well-defined interface for building the SQL queries and HTTP
CF.http
operations of ColdFusion.
For example, the following server-side ActionScript function definition returns a RecordSet
object:
function basicQuery()
{
var mydata = CF.query({datasource:"customers",
sql:"SELECT * FROM myTable"});
return mydata;
}
Using CF.http()
The
CF.http()
HTTP
and
Get
the remote server directly in the URL. This method is often used for a one-way transaction in
which the
CF.http()
method can pass variables to a form or CGI program, and can also create HTTP cookies.
One of the most basic ways to use the
retrieve a page from a specified URL. For example, the following server-side code retrieves file
content from the specified URL:
function basicGet(url)
{
// Invoke with just the url. This is an http get.
result = CF.http(url);
return result.get("Filecontent");
}
In the client-side ActionScript, you call the service function and display the results in the Flash
application, as in the following example:
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.rpc.RelayResponder;
import mx.rpc.ResultEvent;
var myHttpService:Service = new Service(
asr.stock
ActionScript function lets you retrieve information from a remote HTTP server.
methods are supported. Using the
Post
function retrieves an object, such as the contents of a web page. The
cfsuite.asr.stock.stockquotes
is a subdirectory of that mapping. The
Get
function is with the
CF.http()
Using Flash Remoting with server-side ActionScript
method, you send information to
method argument to
Get
, where
CF.query
Post
111
Need help?
Do you have a question about the FLASH REMOTING MX-USING FLASH REMOTING FOR FLASH MX 2004 ACTIONSCRIPT 2.0 and is the answer not in the manual?