问题描述:

In a flex tileList, is there a way to get the cell-address of a given item? i.e. for a given item, get the row/column location for that item in the list.

网友答案:

I've checked the documentation, and no directly, but with a bit of arithmetic you can get yourself sorted.

//asumming this is a change handler
function myTileListChanged(event:Event):void{
    var itemsPerRow:Number = myTileList.dataProvider.length / myTileList.rowCount;
    var selectedRow:int = Math.floor(myTileList.selectedIndex / itemsPerRow);
    var selectedColumn:int = myTileList.selectedIndex - (itemsPerRow * selectedRow);
    trace('index: ' + myTileList.selectedIndex + ' is at row: ' + selectedRow + ' column: ' + selectedColumn);
}

Note, I've used the TileList in Flash, so dataProvider might be slightly different, but you'll still be able to get the picture. HTH!

相关阅读:
Top