开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜