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 includeNetServices.aswhenever you work with recordsets, although // for this simple example, includingRecordSet.aswould 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access