3 Replies Latest reply on May 14, 2009 7:29 PM by Michael Borbor

    Can't get urlLoader to load a local file

    hsfrey

      In FlexBuilder, I'm trying to read an xml file defined in the project, into the program using urlLoader, as shown below.

       

      I get a runtime error saying:  (USSC is the project name)

       

      Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: data/paralog.xml
          at USSC()[C:\Documents and Settings\Admin\My Documents\Flex Builder 3\USSC\src\USSC.mxml:8]
          at _USSC_mx_managers_SystemManager/create()
          at mx.managers::SystemManager/initializeTopLevelWindow()[C:\autobuild\3.2.0\frameworks\proje cts\framework\src\mx\managers\SystemManager.as:3188]
          at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[C:\autobuild\3.2.0\framework s\projects\framework\src\mx\managers\SystemManager.as:3064]
          at mx.managers::SystemManager/docFrameListener()[C:\autobuild\3.2.0\frameworks\projects\fram ework\src\mx\managers\SystemManager.as:2916]

       

      Here's the program:

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
          applicationComplete="loadXML()" >

       

      <mx:Script>
           <![CDATA[
               var xmlData:XML;
              var urlLoader = new URLLoader();

       

      private function loadXML():void
          {    urlLoader.addEventListener(Event.COMPLETE,onXMLLoaded);
              urlLoader.load(new  URLRequest("data/paralog.xml"));
          }

       

      function onXMLLoaded(e:Event):void{
             xmlData =  new XML(e.target.data);
      }
           ]]>
      </mx:Script>
                
          <mx:Panel title="{xmlData.title.toString()}" height="75%" width="75%" layout="vertical"
              horizontalAlign="center" status="status area" >

       

          <mx:TextArea width="50%"
              htmlText="{xmlData.detail.docket.toString()
              + '&lt;br&gt;' + xmlData.detail.date.toString()}"
              />

       

          <mx:VBox width="100%" height="50%">
               <mx:TextArea height="100%" width="50%"
                  editable="false"
                          text="{'Question:' + xmlData.issue.(@id=='i1').question.toString()}"/>
          <mx:HBox width="100%" height="50%">
               <mx:TextArea height="100%" width="50%"
                  editable="false"
                          text="{xmlData.*.claim.(@id=='i1Y').statement.toString()}"/>
               <mx:TextArea height="100%" width="50%"
                  editable="false"
                          text="{xmlData.*.claim.(@id=='i1N1').statement.toString()}"/>
          </mx:HBox>
          </mx:VBox>
           </mx:Panel>  

       

      </mx:Application>

       

      Is my error obvious?

       

      Harvey