Adobe flex:图像列表xml数据提供程序

时间:2013-04-29 13:15:08

标签: flex

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

请帮助我!

以下是我的代码:

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

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

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

Millon谢谢!!

1 个答案:

答案 0 :(得分: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);"/>