How to Change the Style in TileList Selected Item using Flex?
My TileList Contain some text Boxes. i want to change the 开发者_JS百科text color if it's selected. Please any one help me.. Thanks
Test this out, this should solve the issue. There's a custom renderer showing how to see if an item is selected.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:TileList id="tileList">
<mx:dataProvider>
<mx:ArrayCollection>
<mx:Object text="one text"/>
<mx:Object text="two text"/>
<mx:Object text="three text"/>
</mx:ArrayCollection>
</mx:dataProvider>
<mx:itemRenderer>
<mx:Component>
<mx:Canvas horizontalScrollPolicy="off" verticalScrollPolicy="off"
updateComplete="updateTextColor()">
<mx:Script>
<![CDATA[
import mx.controls.TileList;
public var selectedColor:uint = 0xff0000;
public var normalColor:uint = 0xaaaaaa;
protected function updateTextColor():void
{
var selected:Boolean = TileList(this.owner).isItemSelected(this.data);
var color:uint = selected ? selectedColor : normalColor;
textArea.setStyle('color', color);
}
]]>
</mx:Script>
<mx:TextArea id="textArea"
text="{data.text}"/>
</mx:Canvas>
</mx:Component>
</mx:itemRenderer>
</mx:TileList>
</mx:Application>
Best, Lance
精彩评论