Reputation: 2089
How to show the item index in my item renderer.Owner of the item renderer is TileList. http://www.swsd.k12.pa.us/baresvle/mathmaterials/numbers/number_grid.jpg
Upvotes: 0
Views: 4978
Reputation: 377
There's a property in ItemRenderer called itemIndex. It's as simple as that!
Upvotes: 0
Reputation: 2089
private var handleDataChangedEnabled:Boolean = false;
private var myOwner : TileList;
override public function set data(value:Object):void
{
super.data = value;
myOwner = owner as TileList;
if (!handleDataChangedEnabled) {
addEventListener("dataChange", handleDataChanged);
}
}
public function handleDataChanged(event:Event):void {
this.gridValue.text = String((myOwner.dataProvider as ListCollectionView).getItemIndex(data));
}
Add this code to your tileList item renderer , add Label(id gridValue) to display the Grid number.Thanks!
Upvotes: 0
Reputation: 39408
My best guess is try something like this in your itemRenderer:
var index: int = ((listData.owner as TileList).dataProvider as ListCollectionView).getItemIndex())
More info on listData.owner and the listCollectionView.getItemIndex() method.
Upvotes: 4