Using the function results in ActionScript

To use the results returned by server-side ActionScript, you must create a corresponding results function, which is a function defined specifically to handle the results returned by a function that calls a server-side ActionScript. The results function uses a special naming convention that ties it to the function that calls the server-side ActionScript. For example, if you defined a client-side ActionScript function called basicCustomerQuery, you also must create a results function called basicCustomerQuery_result.

The results returned by server-side ActionScript functions differ somewhat depending on whether you are using CF.http or CF.query.

The CF.query function returns a record set, which you manipulate using methods available in the RecordSet ActionScript class object.

The CF.http function returns simple text strings through properties that you reference in your server-side ActionScript.

For more information, see the following sections:

Using results returned by the CF.query function

You access the data returned in a CF.query record set using functions in the RecordSet ActionScript object. Functions in the RecordSet object let you determine how many records are in the record set, what the column names are, and so on. RecordSet functions also let you pull the query data out of the record set. To do so, you reference a specific row number in the record set and use the getItemAt RecordSet function, as in the following example:

// This function populates a Flash text box with data in the first row 
// of the record set under the "email" column name.
function selectData_result ( result )
{
  stringOutput.text =  result.getItemAt(0)["email"];
  _root.employeesView.setDataProvider(result);
}

In the example, the column name is referenced in the getItemAt function between square brackets []. The rows returned by the CF.query function are counted starting from one, so the first row is row 0 (zero), the second row is row 1, and so on.

For more information about coding the server-side CF.query function, see Chapter 3, "Using the CF.query Function".

Using results returned by the CF.http function

The CF.http server-side ActionScript function returns data as simple text. You write server-side functions that reference the properties available in the object returned by the CF.http function. These properties store the file content of the retrieved file, HTTP status codes, the MIME type of the returned file, and so on. On the client side, you create return functions to handle data returned by the CF.http function. You write these functions to handle simple text data.

For more information, see Chapter 4, "Using the CF.http Function".

Comments