6 Replies Latest reply on Jan 7, 2011 7:58 PM by rychoo1984

    Probem on loading from XML file

    rychoo1984

      hello everyone,

      I have a problem with loading images from XML file into portfolio. This is what appears after i try to enter it:

       

      Error: Unable to load ''.
           at mx.controls::SWFLoader/loadContent()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\SWFLoader.as:1898]
           at mx.controls::SWFLoader/load()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\SWFLoader.as:1515]
           at mx.controls::SWFLoader/commitProperties()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\SWFLoader.as:1379]
           at mx.core::UIComponent/validateProperties()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:7933]
           at mx.managers::LayoutManager/validateClient()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:863]
           at mx.core::UIComponent/validateNow()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:7792]
           at spark.components::DataGroup/getVirtualElementAt()[E:\dev\4.x\frameworks\projects\spark\src\spark\components\DataGroup.as:1422]
           at spark.layouts::HorizontalLayout/updateDisplayListVirtual()[E:\dev\4.x\frameworks\projects\spark\src\spark\layouts\HorizontalLayout.as:1676]
           at spark.layouts::HorizontalLayout/updateDisplayList()[E:\dev\4.x\frameworks\projects\spark\src\spark\layouts\HorizontalLayout.as:1974]
           at spark.components.supportClasses::GroupBase/updateDisplayList()[E:\dev\4.x\frameworks\projects\spark\src\spark\components\supportClasses\GroupBase.as:1224]
           at spark.components::DataGroup/updateDisplayList()[E:\dev\4.x\frameworks\projects\spark\src\spark\components\DataGroup.as:1316]
           at mx.core::UIComponent/validateDisplayList()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8709]
           at mx.managers::LayoutManager/validateDisplayList()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:663]
           at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:736]
           at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
      

       

       

      I guess i had to make something wrong in my script, which loads all the stuff from XML, here is the controller handling the portfolio:

      public class PortfolioController
           {
                public function PortfolioController()
                {
                }
                
                private var _pictureList:List;
                private var _portfolioService:HTTPService;
                private var _portfolioData:XML = null;
                private var _imgCollection:XMLListCollection;
                
                [Bindable]
                public function get pictureList():List
                {
                     return _pictureList;
                }
                
                public function set pictureList(value:List):void
                {
                     _pictureList = value;
                     _pictureList.addEventListener(ItemClickEvent.ITEM_CLICK, onItemClickImg);
                }
                
                private function onItemClickImg(event:ItemClickEvent):void
                {
                     navigateToURL(new URLRequest(event.item.url), "_blank");
                }
                     public function loadPortfolioData():void
                {
                     var date:Date = new Date(); 
                     _portfolioService = new HTTPService();
                     _portfolioService.url = "http://rychoo84.vot.pl/xml/pm.xml".concat("?nocache=", date.time);
                     _portfolioService.resultFormat = "e4x";
                     _portfolioService.method = "GET";
                     _portfolioService.addEventListener(ResultEvent.RESULT, onLoadPortfolioData);
                     _portfolioService.send();
                }
                
                private function onLoadPortfolioData(event:ResultEvent):void
                {
                     var obj:Object = event.result;
                     if (obj)
                     {
                          _portfolioData = obj as XML;
                          _imgCollection = new XMLListCollection(_portfolioData.img);
                          pictureList.dataProvider = _imgCollection;
                     }
                }
           }
      }
      

      Finaly here's my XML file:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <portfolio> 
      <img id="1">
        <url>http://eduweb.vipserv.org/images/drzewa.jpg</url>
        <thumbnailurl>http://eduweb.vipserv.org/images/drzewa.jpg</thumbnailurl>
        <text1>...</text1>
        <text2>...</text2>
      </img>
      <img id="2">
        <url>http://eduweb.vipserv.org/images/kobieta.jpg</url>
        <thumbnailurl>http://eduweb.vipserv.org/images/kobieta.jpg</thumbnailurl>
        <text1>...</text1>
        <text2>...</text2>
      </img>
      <img id="3">
        <url>http://eduweb.vipserv.org/images/lodki.jpg</url>
        <thumbnailurl>http://eduweb.vipserv.org/images/lodki.jpg</thumbnailurl>
        <text1>...</text1>
        <text2>...</text2>
      </img>
      <img id="4">
        <url>http://eduweb.vipserv.org/images/puzzle.jpg</url>
        <thumbnailurl>http://eduweb.vipserv.org/images/puzzle.jpg</thumbnailurl>
        <text1>...</text1>
        <text2>...</text2>
      </img>
       </portfolio>
      
      

       

      Has anyone suffered a similar problem as I do? I hope I gave all the needed info to get possible help. I'm using the latest Flash Builder 4.

      Thx in Advance