2013-04-29 34 views
0

我试图用图像提供数据从XML的列表,但是当我运行它...列表是空的!Adob​​e 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> 

米伦感谢!

+0

乍一看,我认为它必须是你的ItemRenderer中的''。 – RIAstar 2013-04-29 13:32:06

+0

谢谢,但它继续空着! TT – jimenator 2013-04-29 15:16:38

+0

该URL是否正确?他们似乎在指向本地资产,而不是指向远程服务器上的文件。 – RIAstar 2013-04-29 15:26:02

回答

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 = [email protected]; 
       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);"/> 
+0

添加image_complete,image_resize,image_click方法。 – Qazi 2013-04-30 09:50:17