|RecordSet Class||Flash 6|
|client-side resultset management|
Appends a row to the end of the recordset.
Adds a row to the recordset at the specified index.
Used to notify an ActionScript object whenever a recordset changes.
Create a new recordset based on filtering an existing recordset.
Returns a list of column names in the recordset.
Returns a specific row in the recordset.
Returns the internal item number of the recordset row.
Returns the number of records in the recordset.
Returns the number of records that have been retrieved from the server.
Returns a Boolean value that tells if the recordset is populated entirely by the server yet.
Returns a flag that tells if a RecordSet object is associated with a server.
Removes all records from the recordset.
Removes a specified record from the recordset.
Replaces the row at the specified index in the recordset.
Sets the delivery mode for pageable recordsets ("ondemand", "fetchall", or "page").
Replaces a single field in a row with a specified value.
Sorts the recordset according to custom criteria.
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 RsDataProviderClass.as file is included automatically when you include the RecordSet.as or NetServices.as files.
To utilize RecordSet objects, the RecordSet.as 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 NetServices.as 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.
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.
Chapter 3 and Chapter 4 for general information and Chapter 5 through Chapter 9 for server-specific details