2 Replies Latest reply on Mar 29, 2008 7:06 PM by ArmyAndy

    Problems with XML and Datagrid!

    ArmyAndy
      Hi!

      Trying to follow a similar idea to the app shown on the flex homepage - i have the following code:

      [code]
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="srv.send()">

      <mx:HTTPService id="srv" url="lab-cs3.cs.st-andrews.ac.uk/~aa322/mytube.xml"/>

      <mx:DataGrid dataProvider="{srv.lastResult.videos.video}"/>



      </mx:Application>
      [/code]

      However, when I run the application - it gives the following error:

      [RPC Fault faultString="Error #2148: SWF file file:///C:/Documents and Settings/Andy/My Documents/Flex Builder 3/HelloWorld/bin-debug/HelloWorld.swf cannot access local resource lab-cs3.cs.st-andrews.ac.uk/~aa322/mytube.xml. Only local-with-filesystem and trusted local SWF files may access local resources." faultCode="InvokeFailed" faultDetail="null"]
      at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\3.0.x\frameworks\projects\rpc\ src\mx\rpc\AbstractInvoker.as:263
      at mx.rpc.http.mxml::HTTPService/ http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\3.0.x\frameworks\projects\rpc\ src\mx\rpc\http\mxml\HTTPService.as:234
      at mx.rpc.http::HTTPService/send()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\http\HTTP Service.as:758]
      at mx.rpc.http.mxml::HTTPService/send()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\http \mxml\HTTPService.as:217]
      at HelloWorld/___HelloWorld_Application1_creationComplete()[C:\Documents and Settings\Andy\My Documents\Flex Builder 3\HelloWorld\src\HelloWorld.mxml:2]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\co re\UIComponent.as:9051]
      at mx.core::UIComponent/set initialized()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:1167]
      at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:698]
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\sr c\mx\core\UIComponent.as:8460]
      at mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src \mx\core\UIComponent.as:8403]

      and fails to connect to the xml i think.

      Any ideas on what I am doing wrong?!

      Thanks

      Andy
        • 1. Re: Problems with XML and Datagrid!
          chris.huston.t10 Level 3
          You need to specify the full URL. I would also suggest using a result handler to assign the xml to your DataGrid dataProvider. Below is a sample. I set the resultFormat to e4x, which is XML.

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="srv.send()">
          <mx:HTTPService id="srv"
          url=" http://lab-cs3.cs.st-andrews.ac.uk/~aa322/mytube.xml"
          result="videoListLoaded(event)"
          resultFormat="e4x"/>
          <mx:Script>
          <![CDATA[
          import mx.rpc.events.ResultEvent;
          [Bindable] private var videoList:XML;
          private function videoListLoaded(evt:ResultEvent):void {
          videoList = evt.result as XML;
          }
          ]]>
          </mx:Script>
          <mx:DataGrid x="10" y="10" id="videos_dg" dataProvider="{videoList.video}">
          <mx:columns>
          <mx:DataGridColumn width="200" headerText="label" dataField="label"/>
          <mx:DataGridColumn width="300" headerText="URL" dataField="url"/>
          <mx:DataGridColumn width="50" headerText="views" dataField="views"/>
          <mx:DataGridColumn width="150" headerText="Category" dataField="category"/>
          </mx:columns>
          </mx:DataGrid>
          </mx:Application>

          Vygo
          • 2. Re: Problems with XML and Datagrid!
            ArmyAndy Level 1
            Thats the stuff - my bad suppose I should have tried the full url - didnt realise without http:// would make such a big difference. Brilliant.

            Thanks very much - I shall no doubt be posting on here again soon!