Hi, Basically I am feeding dataProvider for 2 set of controls: one is on my main app and one is the item renderers of a TileList, both of which are Buttons. I am assigning the same function at main app to handle their click event. The event handler assigned to the controls in the main app works fine but not for those in the item renderers. I get null object at runtime on Button(event.currentTarget).getRepeaterItem(). Below is the code:
<!--code in main Script tag--> public function button_ClickHandler(event:MouseEvent):void { //get the current item. This works for controls that are directly instantiated in main application. But not for nested itemRenderers. See mxml below. var item:Object = Button(event.currentTarget).getRepeaterItem(); var index:int = taskList.getItemIndex(item); if(index != -1) { taskList.removeItemAt(index); taskList.addItemAt(item, 0); } } <mx:ArrayCollection id="taskList"> <mx:Object label="Word"/> <mx:Object label="Media Player"/> <mx:Object label="Contacts"/> <mx:Object label="Apache Server"/> <mx:Object label="Dictionary"/> <mx:Object label="iTunes"/> <mx:Object label="Solitaire"/> <mx:Object label="Minesweeper"/> <mx:Object label="Safari"/> <mx:Object label="RSS Reader"/> </mx:ArrayCollection> <!--code for item renderers--> <mx:TileList dataProvider="{taskList}"> <mx:itemRenderer> <mx:Component> <mx:Button styleName="myButtonStyle" click="parentDocument.button_ClickHandler(event);"/> </mx:Component> </mx:itemRenderer> </mx:TileList> I tried to trace and it seems the Buttons inside itemRenderer can access the dataProvider in the outer document. But getCurrentItem() breaks. So how do I get the "current item" from the currentTarget?