DataSet.next()

I’m using a DataSet component to manage a photo gallery…

when a thumbnail is clicked a DataSet.find() is done to get the id of the thumbnail to load the large scaled version of it.However, on a “next” button click using DataSet.next() doesn’t seem to load the “next” item in the collection (or maybe it does but it doesn’t coincide with what has been listed in order as expected by the thumbnail listing.) I’m not sure I understand how the DataSet.find() works but this is what I have so far

[AS]
if(!_photosDataSet.hasSort(‘sortByID’)){
_photosDataSet.addSort(“sortByID”, [“id”]);
}

    if (_photosDataSet.find([_id])) {
        itemID = _photosDataSet.getItemId();
    }
    // Now use locateByID() to position the current iterator
    // on the item in the collection whose ID matches studentID.
    if (itemID != null) {
        _photosDataSet.locateById(itemID);
    }
    
    var d:Object = _photosDataSet.currentItem;
    _photosDataSet.removeSort("sortByID");

[/AS]

[AS]

if (!_gallery._photosDataSet.hasNext()) {
return false;
}
_gallery._photosDataSet.next();
var _photoData:Object = _gallery._photosDataSet.currentItem;
displayPhoto(_photoData);
[/AS]

I have tried setting resetting the iterator or selectedIndex but it doesn’t seem to work out right…What am I not understanding here?