また、TileListData を拡張し、isNew プロパティなどを追加する必要があります。簡単な回避策は、iconプロパティを使用して Boolean を格納することです。これは ListData.as のオブジェクトであるため、クラスでそれにアクセスし、それを使用して新しいグラフィックの表示を切り替えます。
例えば
package
{
import fl.controls.listClasses.ICellRenderer;
import fl.controls.listClasses.ImageCell;
import fl.controls.listClasses.ListData;
import fl.controls.listClasses.TileListData;
import fl.controls.TileList;
import fl.data.DataProvider;
import fl.managers.StyleManager;
import flash.events.EventDispatcher;
import flash.events.*;
import flash.display.Sprite;
import fl.containers.UILoader;
public class CustomImageCell extends ImageCell implements ICellRenderer
{
protected var isNewGraphic:Sprite;
public function CustomImageCell()
{
super();
//do other stuff here
loader.scaleContent = false;
loader.addEventListener(IOErrorEvent.IO_ERROR, handleErrorEvent, false, 0, true);
loader.addEventListener(Event.COMPLETE, handleCompleteEvent, false, 0, true);
useHandCursor = true;
}
override protected function configUI():void {
super.configUI();
//add your NEW graphic here
isNewGraphic = new Sprite();
isNewGraphic.graphics.beginFill(0x990000,0.75);
isNewGraphic.graphics.lineTo(10,0);
isNewGraphic.graphics.lineTo(30,30);
isNewGraphic.graphics.lineTo(30,40);
isNewGraphic.graphics.lineTo(0,0);
isNewGraphic.graphics.endFill();
addChild(isNewGraphic);
}
override protected function drawLayout():void
{
var imagePadding:Number = getStyleValue("imagePadding") as Number;
loader.move(11, 5);
var w:Number = width-(imagePadding*2);
var h:Number = height-imagePadding*2;
if (loader.width != w && loader.height != h)
{
loader.setSize(w,h);
}
loader.drawNow(); // Force validation!
//position NEW graphic here
isNewGraphic.x = width-isNewGraphic.width;
}
//toggle graphic here based on data provider for item
override public function set listData(value:ListData):void {
_listData = value;
label = _listData.label;
var newSource:Object = (_listData as TileListData).source;
if (source != newSource) { // Prevent always reloading...
source = newSource;
}
isNewGraphic.visible = Boolean(_listData.icon);//hacky use of the icon property
}
//make sure NEW graphic is on top when the load is complete
protected function handleCompleteEvent(event:Event):void{
swapChildren(loader,isNewGraphic);
}
override protected function handleErrorEvent(event:IOErrorEvent):void {
trace('ioError: ' + event);
//dispatchEvent(event);
}
}
}
そして、ここにいくつかのテストタイムラインコードがあります:
import fl.controls.*;
import fl.data.DataProvider;
var tileList:TileList = new TileList ();
tileList.move(10,10);
tileList.setSize(400, 300);
tileList.columnWidth = 215;
tileList.rowHeight = 300;
tileList.direction = ScrollBarDirection.VERTICAL;
tileList.setStyle("cellRenderer", CustomImageCell);
addChild(tileList);
tileList.dataProvider = getRandomDP(10);
function getRandomDP(size:int):DataProvider {
var result:DataProvider = new DataProvider();
for(var i:int = 0; i < size; i++) result.addItem({label:'item'+i,source:'http://digitalsubdivide.com/wp-content/uploads/2010/08/stackoverflow-300.png',icon:Math.random() > .5});
return result;
}
HTH