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.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();
}
trace("After:");
traceItems();
// Tell the dataset it's time to update the controls now.
my_ds.enableEvents();
function traceItems(label:String):Void {
for (var i:Number = 0; i < my_ds.length; i++) {
trace("\t" + my_ds.items[i].name + " - $" + my_ds.items[i].price);
}
trace("");
}
DataSet.loadFromSharedObj()
Availability
Flash Player 7.
Edition
Flash MX Professional 2004.
382
Components Dictionary
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?
Questions and answers