Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > DataSet component > DataSet.createItem() | |||
Flash Player 7.
Flash MX Professional 2004.
dataSetInstance.createItem([itemData])
itemData Data associated with the item. This parameter is optional.
The newly constructed item.
Method; creates an item that isn't 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 object's 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.
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);
};
DataSet.itemClassName, DataSet.newItem, DataSet.schema
Flash CS3