RecordSet Class

RecordSet ClassFlash 6

client-side resultset management


addItem( )

Appends a row to the end of the recordset.

addItemAt( )

Adds a row to the recordset at the specified index.

addView( )

Used to notify an ActionScript object whenever a recordset changes.

filter( )

Create a new recordset based on filtering an existing recordset.

getColumnNames( )

Returns a list of column names in the recordset.

getItemAt( )

Returns a specific row in the recordset.

getItemID( )

Returns the internal item number of the recordset row.

getLength( )

Returns the number of records in the recordset.

getNumberAvailable( )

Returns the number of records that have been retrieved from the server.

isFullyPopulated( )

Returns a Boolean value that tells if the recordset is populated entirely by the server yet.

isLocal( )

Returns a flag that tells if a RecordSet object is associated with a server.

removeAll( )

Removes all records from the recordset.

removeItemAt( )

Removes a specified record from the recordset.

replaceItemAt( )

Replaces the row at the specified index in the recordset.

setDeliveryMode( )

Sets the delivery mode for pageable recordsets ("ondemand", "fetchall", or "page").

setField( )

Replaces a single field in a row with a specified value.

sort( )

Sorts the recordset according to custom criteria.

sortItemsBy( )

Sorts the recordset by a specified field.


The RecordSet class defines ActionScript objects that can be created on the client to create a multidimensional array that is indexed sequentially, starting with 0. A RecordSet object mimics the functionality of a server-side resultset. If you return a resultset from a Flash Remoting method on the server, it will automatically be cast into a RecordSet object in the Flash movie. Refer to Chapter 5 through Chapter 9 and Appendix A for datatype conversions on the various platforms.

The index of each row of the recordset is a sequential number from 0 to the length of the recordset minus one. In other words, a recordset containing 10 rows has index numbers from 0 to 9. There is also an internal identifier number, which should not be confused with the index number. The index number can change if you add or delete rows or sort the recordset. The internal identifier number is a sequential number that is assigned to each row and remains attached to that row. If a row is deleted, the internal identifying number is not used again and the internal ID numbers of remaining rows does not change (although their index numbers might). Similarly, if a recordset is sorted, the internal identifiers remain attached to each individual row. The internal identifier can be read with the getItemId( ) method, or as a property of the recordset row:

myID = myRecordset_rs.getItemAt(0)._  _ID_  _

The RecordSet class is a subclass of the RsDataProviderClass class. Much of the RecordSet class's functionality comes from its superclass. The file is included automatically when you include the or files.

To utilize RecordSet objects, the file must be included in the Flash movie. This file can be included on its own if you are not using Flash Remoting, but it is included automatically when you include the file. To create a client-side RecordSet object from scratch, instantiate it like so:

var myRecordset_rs = new RecordSet(["First", "Last", "Phone", "Fax", "Email"]);

The ActionScript naming convention for RecordSet objects is to use _rs at the end of your RecordSet object's variable name. This ensures that code hints work in the Flash and Dreamweaver authoring environments.

A typical RecordSet object is created by calling a method on the server that issues a SELECT statement against a database and returns a resultset. The resultset is returned to the Flash movie, and the resultset is automatically turned into a client-side RecordSet object. The field names in your database query become the field names in the RecordSet object. The object has many built-in methods that allow the developer to interact with the recordset as one would on an application server.

The RecordSet class is one of the cornerstones of Flash Remoting, because it allows the seamless integration of databases into a client-side Flash movie by allowing the developer to call remote services that return resultsets.

Methods of the RecordSet class are discussed at length under "The RecordSet Object" in Chapter 4. This chapter provides a more formal discussion of each method's syntax, in alphabetical order. Consult Chapter 4 for a different perspective on each method covered here. For readability's sake, I use the informal term "recordset" interchangeably with the more formal "RecordSet object" where the distinction is obvious or irrelevant.


The initial release of Flash Remoting had a problem with J2EE resultsets. The client-side RecordSet object did not automatically get created by Flash Remoting. Updater 1 fixes the problem.

See Also

Chapter 3 and Chapter 4 for general information and Chapter 5 through Chapter 9 for server-specific details

    Part III: Advanced Flash Remoting