<mx:VBoxxmlns:mx="http://www.adobe.com/2006/mxml" implements="mx.controls.listClasses.IDropInListItemRenderer"> <mx:Script> <![CDATA[ import mx.controls.listClasses.BaseListData; import mx.controls.Button; import mx.controls.TileList; import mx.events.FlexEvent; import mx.controls.listClasses.IDropInListItemRenderer; privatevar _listData:BaseListData; [Bindable] publicvar key:String; //the list parent of this renderer privatevar tileList:SelectedChildrenTileList; override publicfunction set data(value:Object):void { super.data = value; this.invalidateProperties(); dispatchEvent(newFlexEvent(FlexEvent.DATA_CHANGE)); } [Bindable("dataChange")] publicfunction get listData():BaseListData {return _listData; } publicfunction set listData( value:BaseListData ):void { //set the list data _listData = value; //get access to the tile list tileList = _listData.owner as SelectedChildrenTileList; //finally, track this item's unique ID that all items //in a BaseListData are assigned key=_listData.uid; } privatefunction onToggle(event:Event):void { var i:int = tileList.toggledButtons.getItemIndex(key); //if the key of this renderer appears in the list of toggled buttons,then remove it if (i != -1 && (event.target as Button).selected==false ){ tileList.toggledButtons.removeItemAt(i); } //if the key of this renderer doesn't appear in the list of toggled buttons, then add it if (i == -1 && (event.target as Button).selected == true ) { tileList.toggledButtons.addItem(key) } tileList.invalidateList(); } override protectedfunction updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth,unscaledHeight); if(key){ var i:int= tileList.toggledButtons.getItemIndex(key); //sometimes putting your if/else on one line makes things neater,not always, but sometimes if (i != -1){ toggleBtn.selected=true ; } else { toggleBtn.selected = false ; } } }