RecordSet.addItemAt( )


RecordSet.addItemAt( ) Method Flash 6

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

Arguments

index

An integer from to the length of the recordset minus one.

record

An object with properties that match the fields of the existing RecordSet object.

Description

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.

Example

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 ) is the last one that was added, because the addItemAt( ) method was used to insert the record at the 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



Flash Remoting
Flash Remoting: The Definitive Guide
ISBN: 059600401X
EAN: 2147483647
Year: 2003
Pages: 239
Authors: Tom Muck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net