RecordSet.addItemAt( )

RecordSet.addItemAt( ) MethodFlash 6

adds a record at the specified index of a recordset
myRecordSet.addItemAt(index, record)



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 ""
var myRecordset_rs = new RecordSet(["First", "Last", "Email"]);
myRecordset_rs.addItem({First:"Tom", Last:"Muck", Email:""});
myRecordset_rs.addItem({First:"Jack", Last:"Splat", Email:""});
myRecordset_rs.addItemAt(0,{First:"Biff", Last:"Bop", Email:""});

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

See Also

RecordSet.addItem( ); Chapter 4

    Part III: Advanced Flash Remoting