這看起來應該很簡單,但我是Flex的總新手,並且陷入困境。使用哈希ArrayList作爲TileLayout dataProvider
這就是我現在所擁有的,它的工作原理:
<s:List id="list"
itemRenderer="spark.skins.spark.DefaultComplexItemRenderer"
horizontalCenter="0"
verticalCenter="0">
<s:layout>
<s:TileLayout requestedColumnCount="3"
requestedRowCount="2"
horizontalGap="0"
verticalGap="0" />
</s:layout>
<s:dataProvider>
<s:ArrayList>
<s:BitmapImage source="@Embed('../images/menus/car_types/truck.png')" />
<s:BitmapImage source="@Embed('../images/menus/car_types/suv.png')" />
<s:BitmapImage source="@Embed('../images/menus/car_types/convertible.png')" />
<s:BitmapImage source="@Embed('../images/menus/car_types/sedan.png')" />
<s:BitmapImage source="@Embed('../images/menus/car_types/surprise.png')" />
</s:ArrayList>
</s:dataProvider>
</s:List>
我想要做的就是添加的每個瓦片下面的標籤,用繩子每個圖像相關聯。我想要做類似
<s:List id="list"
itemRenderer="spark.skins.spark.DefaultComplexItemRenderer"
horizontalCenter="0"
verticalCenter="0">
<s:layout>
<s:TileLayout requestedColumnCount="3"
requestedRowCount="2"
horizontalGap="0"
verticalGap="0" />
</s:layout>
<s:dataProvider>
<s:ArrayList>
<s:BitmapImage name="Truck" source="@Embed('../images/menus/car_types/truck.png')" />
<s:BitmapImage name="SUV" source="@Embed('../images/menus/car_types/suv.png')" />
<s:BitmapImage name="Convertible" source="@Embed('../images/menus/car_types/convertible.png')" />
<s:BitmapImage name="Sedan" source="@Embed('../images/menus/car_types/sedan.png')" />
<s:BitmapImage name="Surprise Me!" source="@Embed('../images/menus/car_types/surprise.png')" />
</s:ArrayList>
</s:dataProvider>
</s:List>
但由於BitmapImage對象上沒有名稱屬性,所以出現錯誤。
我想我需要把每BitmapImage
在Object
,並放在一個字符串作爲對象的屬性,但我無法弄清楚如何做到這一點。這是我最好的猜測,但我不知道如何爲BitmapImage
指定屬性名:
<fx:Object label="Truck">
<s:BitmapImage source="@Embed('../images/menus/car_types/truck.png')" />
</fx:Object>
在那之後,我想我會做一個定義ItemRenderer讀出每一個對象的屬性?
TIA
太棒了,那就是我一直在尋找的東西。至於BitmapImage,我曾經以爲你必須創建一個UI組件來嵌入圖像(我不想動態加載),所以我認爲這是動機的一部分...雖然我想回想起沒有多大意義。感謝您澄清一切! – unsorted