在flex tileList中,有没有一种方法可以获得给定项目的单元地址?即对于给定的项目,获取该项目在列表中的行/列位置。
发布于 2009-08-31 19:04:07
我已经检查了文档,没有直接,但通过一些算术,你可以让你自己排序。
//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);
}请注意,我在闪存中使用了TileList,因此dataProvider可能会略有不同,但您仍然可以获得图片。哈!
https://stackoverflow.com/questions/1358405
复制相似问题