0

我正在尝试使用提供来自 xml 的数据的图像创建一个列表,但是当我运行它时......列表是空的!

请帮我!

这是我的代码的一部分:

主要.mxml:

<s:List bottom="15" width="50%" height="20%" dragEnabled="true" horizontalCenter="-2"
horizontalScrollPolicy="on" itemRenderer="hListItemRenderer">
    <s:dataProvider>
        <s:XMLListCollection source="{gallery.children()}"/>
    </s:dataProvider>
</s:List>

项目渲染器.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx" 
     autoLayout="true">

<s:Image source="{data.children()}" />

</s:ItemRenderer>

画廊.xml:

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/03/08/creating-a-simple-image-gallery-with-the-flex-tilelist-control/ -->
<gallery>
<image img="assets/wheelchair0.jpg"/>
<image
        img="assets/10275402-icono-de-la-television-tv-reciclado-papel-palo-sobre-fondo-de-color-de-pantalla-retro-grunge.jpg" />
</gallery>

</xml>

米伦谢谢!!

4

1 回答 1

0
gallery.xml
<?xml version="1.0" encoding="utf-8"?>
<gallery>
    <image title="Certificate 1"
        thumbnailImage="assets/T1.JPG"
        fullImage="assets/1.JPG" />
    <image title="Certificate 2"thumbnailImage="assets/T2.JPG"fullImage="assets/2.JPG" />
    <image title="Certificate 3"thumbnailImage="assets/T3.JPG"fullImage="assets/3.JPG" />
</gallery>
-- End gallery.xml
private var img:Image;
        private function tileList_itemClick(evt:ListEvent):void {
                img = new Image();
                img.width = 900;
                img.height = 800;
                img.maintainAspectRatio = true;
                img.addEventListener(Event.COMPLETE, image_complete);
                img.addEventListener(ResizeEvent.RESIZE, image_resize);
                img.addEventListener(MouseEvent.CLICK, image_click);
                img.source = evt.itemRenderer.data.@fullImage;
                img.setStyle("addedEffect", image_addedEffect);
                img.setStyle("removedEffect", image_removedEffect);
                PopUpManager.addPopUp(img, this, true);
            }



<mx:XML id="xml" source="gallery.xml" />
<mx:XMLListCollection id="xmlListColl" source="{xml.image}"/>
<mx:TileList id="tileList"  width="700" height="250"
                     dataProvider="{xmlListColl}" verticalAlign="middle"
                     itemRenderer="CustomItemRenderer"
                     columnCount="3"
                     columnWidth="230"
                     rowCount="1"
                     rowHeight="450"
                     verticalScrollPolicy="off" horizontalScrollPolicy="off"
                     itemClick="tileList_itemClick(event);"/>
于 2013-04-30T09:48:32.913 回答