The RecordSet object can be used with or without Flash Remoting MX. The object itself is a sophisticated array of objects that operates as a standard database query result set. A series of methods and properties are available to interact with the data inside the object. This is a standard ActionScript object that can be sent to a method or occupy a slot on a SharedObject. The server-side and client-side RecordSet objects are identical. On both platforms, you must manually load the RecordSet libraries to begin using them. On the server, the RecordSet class is loaded automatically with the command: load("NetServices.asc"); On the client, the RecordSet class is loaded automatically with the command: #include "NetServices.as" To enable Code Hints and Code Completion in the Flash MX ActionScript Editor, use the suffix _rs in the name of the RecordSet variable. Recordset MethodsRecordSet.addItem(record)Inserts a new record into the RecordSet.
RecordSet.addItemAt(index, record)Inserts a record at a precise row number. This overwrites any data that exists at that row number. Rows start at 0.
RecordSet.filter(filterFunction, context)Creates and calls a function that you create to query the RecordSet. The results populate a new RecordSet with references to the original RecordSet.
RecordSet.getColumnNames()Returns a string list with the names of the columns (fields) of the RecordSet. RecordSet.getItemAt(index)Returns a record by row (index) number. The record is returned as an object with the columns as properties. For example: my_rs.getItemAt(5).myColumn; returns the value of the column myColumn at row 5. The single parameter is:
RecordSet.getLength()Returns the available length, or total number of records, of the RecordSet. RecordSet.getNumberAvailable()Returns the total length (or total number of records) of the RecordSet. This method returns the length reported by the application server before the records have arrived, accounting for slow network connections and large RecordSets. RecordSet.removeAll()Deletes all records from the RecordSet leaving an empty RecordSet, for which length equals 0. RecordSet.removeItemAt(index)Deletes a record from the RecordSet and locks the reuse of the index number.
RecordSet.replaceItemAt(index, record)Replaces a complete record that exists at an index value in the RecordSet.
RecordSet.setDeliveryMode = function(mode, pagesize, numPrefetchPages)Sets the way in which Flash receives RecordSets from a Flash Remoting MX server. By default, it receives the entire RecordSet when it is ready. Setting a different mode affects how records will be requested and received. Use this function with the isFullyPopulated function to ensure the integrity of the RecordSet.
RecordSet.setField(index, fieldName, value)Replaces the value of a single field within a RecordSet at a defined index.
RecordSet. sort (compareFunction)Sorts records within a RecordSet using a custom compare function:
RecordSet.sortItemsBy(fieldName, direction)Sorts records within a RecordSet by field name. This will not make a duplicate copy of the RecordSet. The sorting key is the value or data within the field.
RecordSet PropertiesRecordSet.isFullyPopulated() returns a Boolean value. True indicates a fully populated RecordSet. RecordSet.isLocal() returns a Boolean value. True means the RecordSet was created locally or from an application server. RecordSet EventRecordSet.addView(InfoObject) is invoked when a RecordSet is changed. This method receives an Information object (or event descriptor) that contains two parameters: event and description . Refer to the list of Information objects in Appendix C for a complete list of messages that can be received. This could be used to trigger a SharedObject broadcast. |