User Guide
356 Components Dictionary
DataSet.disableEvents()
Availability
Flash Player 7.
Edition
Flash MX Professional 2004.
Usage
dataSetInstance.disableEvents()
Returns
Nothing.
Description
Method; disables events for the DataSet object. While events are disabled, no user interface
controls (such as a DataGrid component) are updated when changes are made to items in the
collection, or when the DataSet object is scrolled to another item in the collection.
To reenable events, you must call
DataSet.enableEvents(). The disableEvents()
method can be called multiple times, and
enableEvents() must be called an equal number
of times to reenable the dispatching of events.
Example
In the following example, events are disabled before changes are made to items in the
collection, so that the DataSet object won’t affect performance by trying to refresh controls:
my_ds.addEventListener("modelChanged", onModelChanged);
function onModelChanged(evt_obj:Object):Void {
trace("model changed, DataSet now has " + evt_obj.target.items.length + "
items");
}
// Disable events for the data set.
my_ds.disableEvents();
my_ds.addItem({name:"Apples", price:14});
my_ds.addItem({name:"Bananas", price:8});
trace("Before:");
traceItems();
my_ds.last();
while(my_ds.hasPrevious()) {
my_ds.price *= 0.5; // Everything's 50% off!
my_ds.previous();
}