我有一个对象的 ArrayCollection。我将此数组作为数据提供者传递给水平列表,并且我正在使用自定义 itemRenderer。
执行应用程序时,显示水平列表
[object CustomClass][object CustomClass][object CustomClass][object CustomClass]
我尝试在 itemrenderer 中强制转换每个对象,如下所示:
<mx:Label text="{(data as CustomClass).label1}"/>
但它不工作...
感谢您的任何帮助,您可以提供。问候,
BS_C3
编辑 - 2010 年 3 月 9 日
让我们再看一些代码 =)
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Component id="Item">
<mx:VBox width="180">
<mx:HBox width="100%">
<mx:Spacer width="100%"/>
<mx:Button label="x"/>
</mx:HBox>
<mx:Image id="thumbnail"/>
<mx:Label width="100%" horizontalCenter="0" text="Collection"/>
<mx:HBox width="100%">
<mx:Label width="100" text="GIA"/>
<mx:Label text="{data.charg_st}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Finger Size"/>
<mx:Label text="xxxxxx"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Carat"/>
<mx:Label text="{data.carats}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Color"/>
<mx:Label text="{data.color}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Clarity"/>
<mx:Label text="{data.clarity}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Shop"/>
<mx:Label text="{data.lgort_fp}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Resizing"/>
<mx:Label text="{data.resizing}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Price Excl. VAT"/>
<mx:Label text="{data.net_price_fp}"/>
</mx:HBox>
</mx:VBox>
</mx:Component>
<mx:HorizontalList
dataProvider="{GlobalData.instance.tray}"
columnCount="4"
rowCount="1"
horizontalScrollPolicy="off"
itemRenderer="{Item}"
/>
</mx:Canvas>
仅供参考,horizonalList 数据提供者是对象的 ArrayCollection。
现在,水平列表正在显示空项目......具有正确的宽度...... arraycollection 不为空(我在项目的点击事件上使用警报,并且我确实检索了预期的数据)。
希望这会有所帮助>_<
问候,BS_C3