RecordSet.addItemAt( ) Method | Flash 6 |
adds a record at the specified index of a recordset |
An integer from 0 to the length of the recordset minus one.
An object with properties that match the fields of the existing RecordSet object.
The addItemAt( ) method inserts a record at a specified location by passing an index number to the recordset along with the record being inserted. It differs from addItem( ) in that the record need not be appended to the end of the recordset but rather can be inserted at any valid index.
The following code creates a RecordSet object, adds two rows using the addItem( ) method, then adds another row using addItemAt( ):
#include "RecordSet.as" var myRecordset_rs = new RecordSet(["First", "Last", "Email"]); myRecordset_rs.addItem({First:"Tom", Last:"Muck", Email:"tom@tom-muck.com"}); myRecordset_rs.addItem({First:"Jack", Last:"Splat", Email:"jack@tom-muck.com"}); myRecordset_rs.addItemAt(0,{First:"Biff", Last:"Bop", Email:"biff@tom-muck.com"});
At this point, the first record (at index 0) is the last one that was added, because the addItemAt( ) method was used to insert the record at the 0 position within the recordset. However, the internal identifier of this record is 2 because it was added third:
trace(myRecordset_rs.getItemId(0)); // Returns 2
RecordSet.addItem( ); Chapter 4