User Guide

352 Components Dictionary
Description
Method; creates an item that isnt associated with the collection. You can specify the class of
object created by using the
DataSet.itemClassName property. If no
DataSet.itemClassName value is specified and the itemData parameter is omitted, an
anonymous object is constructed. This anonymous objects properties are set to the default
values based on the schema currently specified by
DataSet.schema.
When this method is invoked, any listeners for the
DataSet.newItem event are notified and
are able to manipulate the item before it is returned by this method. The optional item data is
used to initialize the class specified with the
DataSet.itemClassName property or is used as
the item if
DataSet.itemClassName is blank.
A
DataSetError exception is thrown when the class specified with the
DataSet.itemClassName property cannot be loaded.
Example
my_ds.addEventListener("newItem", newItemListener);
function newItemListener(evt_obj:Object):Void {
trace("new item was added: {name:'" + evt_obj.item.name + "', years:" +
evt_obj.item.years + "}");
}
my_ds.addItem(my_ds.createItem({name:"Wilson", years:3}));
my_ds.addItem({name:"Tom", years:2});
my_ds.filtered = true;
my_ds.filterFunc = function(item:Object):Boolean {
return (item.years % 2 == 0);
};
See also
DataSet.itemClassName, DataSet.newItem, DataSet.schema
DataSet.currentItem
Availability
Flash Player 7.
Edition
Flash MX Professional 2004.
Usage
dataSetInstance.currentItem