DataSet.length

Availability

Flash Player 7.

Edition

Flash MX Professional 2004.

Usage

dataSetInstance.length

Description

Property (read-only); specifies the number of items in the current view of the collection. The viewable number of items is based on the current filter and range settings.

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("");
}

Flash CS3