User Guide

DataSet component (Flash Professional only) 307
DataSet.addItem
Availability
Flash Player 7.
Edition
Flash MX Professional 2004.
Usage
on(addItem) {
// insert your code here
}
listenerObject = new Object();
listenerObject.addItem = function (eventObj) {
// insert your code here
}
dataSet.addEventListener("addItem", listenerObject)
Description
Event; generated just before a new record (transfer object) is inserted into this collection.
If you set the
result property of the event object to false, the add operation is canceled; if you
set it to
true, the add operation is allowed.
The event object (
eventObj) contains the following properties:
target The DataSet object that generated the event.
type The string "addItem".
item A reference to the item in the collection to be added.
result A Boolean value that specifies whether the specified item should be added. By default,
this value is
true.
Example
The following on(addItem) event handler (attached to a DataSet object) cancels the addition of
the new item if a user-defined function named
userHasAdminPrivs() returns false; otherwise,
the item addition is allowed.
on(addItem) {
if(globalObj.userHasAdminPrivs()) {
// Allow the item addition.
eventObj.result = true;
} else {
// Don’t allow item addition; user doesn’t have admin privileges.
eventObj.result = false;
}
}
See also
DataSet.removeItem