O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

21.1. Creating Recordsets

Problem

You want to create and populate a recordset.

Solution

Return a recordset from Flash Remoting, or create a recordset using the constructor and populate it using the RecordSet.addItem( ) or RecordSet.addItemAt( ) methods.

Discussion

Most often, recordsets are returned to Flash movies from Flash Remoting. Recordsets cannot be meaningfully passed back to an application server portion of a Flash Remoting application. Therefore, it is rarely necessary to create recordsets with ActionScript. However, recordsets can be a convenient way of storing data, and with the DataGlue class, the data within a recordset can be used to populate many UI components.

The constructor function for recordsets requires an array of column names as a parameter, as follows:

// Make sure to include NetServices.as whenever you work with recordsets, although 
// for this simple example, including RecordSet.as would suffice.
#include "NetServices.as"

// Create a new recordset with three columns: COL0, COL1, and COL2.
rs = new RecordSet(["COL0", "COL1", "COL2"]);

Once you have created a recordset using the constructor, you can add records to it using the addItem( ) and addItemAt( ) methods. Both methods require a record object parameter. A record object is merely an object (an instance of the Object class) in which the property names match the column names of the recordset. The addItemAt( ) method differs from the addItem( ) method in that addItemAt( ) inserts a new record at a specific ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required