如何在 Flex 中显示数组中的图像?

发布于 2024-10-27 02:22:18 字数 213 浏览 9 评论 0原文

我正在 Flex 中制作一个配对游戏。我想要左侧一个数组中的图像和右侧第二个数组中的图像,以便用户可以将左侧的图像拖放到右侧的匹配图像上。

我里面有 mx:HBox 和两个 mx:VBox 。现在,如果数组的长度(图像数量)可能不同,如何在我的 gameArray 中的 VBox 中显示图像?我必须创建与 gameArray 长度一样多的 mx:Image,但是如何在 MXML 中执行此操作?

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 the length of my gameArray, but how do I do it in MXML?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情归归情 2024-11-03 02:22:18

为什么不将 ListitemRenderer 来显示图像?

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

江城子 2024-11-03 02:22:18

我将所有数据都放在一个数组中,并且更喜欢这样保存。我只是不明白为什么我的代码不起作用...

<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>

代码直接取自 http://livedocs.adobe.com/flex/3/html/help.html?content=repeater_3.html

为什么不显示图像?我调试了代码以确保数组具有正确的数据。例如 gameArray[1] 中的字符串将是“assets/image.jpg”,如果我只是将其写为源,它就可以工作。对于动态,则不然。也许 rp.currentItem 不完全是我在这种情况下应该使用的?

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??

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文