質問

I've implemented a custom cell renderer for the TileList component by extending the ImageCell class like this:

package 
{
   import fl.controls.listClasses.ICellRenderer;
   import fl.controls.listClasses.ImageCell;
   import fl.controls.Label;

   public class CustomImageCell extends ImageCell implements ICellRenderer
   {
      public var lblName:Label;

      public function CustomImageCell() 
      {
          lblname = new Label();
          addChild(lblName);
      }
   }
}

I assigned it like this:

tilelist.setStyle("cellRenderer", CustomImageCell);

now when I add items to the tilelist, how would pass some text to that label in the cell renderer?

tilelist.addItem({label:"Let this text go to the lblName", source:new Bitmap(bData)});

EDIT:

I'm doing this because I need TileList's items' label to be multiline, and I was told the only way to do that is to implement a custom Cell Renderer.

役に立ちましたか?

解決

Found the answer. You have to override set data method and assign a value to your variable from there:

override public function set data(value:Object):void {
        _data = value;
        if(_data.label) lblName.text =_data.label;
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top