把itemrender看成一个视图,所以渲染器本身不做任何计算,只检查对象的值...
如果我理解正确,我会做这样的事情......
(也许您需要将检查从设置数据移动到更新显示列表)
例子:
class Test
{
public var col1:String = "Everything";
public var col3:String = "Cars";
public function get color():uint
{
if (col1 == "Everything")
return 0xff0000;
return 0x000000;
}
}
itemrendererA.mxml
override public function set data(value:Object):void
{
super.data = value;
if (super.data != null && super.data is Test)
{
// do what you need to do..
lbl1.text = (super.data as Test).col1;
lbl1.setStyle("color", (super.data as Test).color);
}
}
itemrendererB.mxml
override public function set data(value:Object):void
{
super.data = value;
if (super.data != null && super.data is Test)
{
if ( (super.data as Test).color == 0xff0000)
// do something
else
// do something else
}
}
如果这不是您要查找的内容,请添加一些代码...