开发者

How to display images from an array in Flex?

开发者 https://www.devze.com 2023-02-20 00:40 出处:网络
I\'m making a Matching Game in Flex. I want to have images from one array on my left and images from the second array on my right, so that user can drag&drop images from the left onto matching ima

I'm making a Matching Game in Flex. I want to have images from one array on my left and images from the second array on my right, so that user can drag&drop images from the left onto matching images on the right.

I have mx:HBox and two mx:VBox inside. Now, how can I display images in VBox that I have in my gameArray, if the length of my array (amount of images) may differ? I would have to create as many mx:Image as t开发者_JAVA技巧he length of my gameArray, but how do I do it in MXML?


Why not use a List with an itemRenderer to display the image?


I have all my data in an array and prefer to keep it like this. I just dont understand why my code doesn't work...

<mx:ArrayCollection id="myAC" source="{gameArray}"/>
<mx:VBox width="50%" height="100%">
<mx:Repeater id="rp" dataProvider="{myAC}">
<mx:Image source="{rp.currentItem}"/>
</mx:Repeater>
</mx:VBox>

The code is taken straight from http://livedocs.adobe.com/flex/3/html/help.html?content=repeater_3.html

Why doesn't it display the images? I debugged my code to make sure that the array has correct data. The string in, e.g. gameArray[1] will be "assets/image.jpg" and if I just write it as a source, it works. With dynamic, it does not. Maybe rp.currentItem is not exactly what I should use in this case??

0

精彩评论

暂无评论...
验证码 换一张
取 消