4 Replies Latest reply on Sep 29, 2006 4:57 PM by Kwooda

    Array collections vs. HTTPService

    Kwooda Level 1
      I have a demo Flex app I wrote in Beta 3 that worked great, and now I have imported it into Flex 2 (trial) and am having a problem.

      Early on, I declare:
      [Bindable] public var datPurpose:ArrayCollection;

      and at some point an HTTPService is called to retrieve a static XML file, and the result handler attempts to process the data, but throws an error on this line:
      datPurpose = new ArrayCollection(xmlData.lastResult.purpose.resource);

      The full text of the error is as follows:

      TypeError: Error #1034: Type Coercion failed: cannot convert mx.collections::ArrayCollection@431d791 to Array.
      at Resources/Resources::xmlDataResult()[C:\FlexProjects\Resources\Resources.mxml:113]
      at Resources/__xmlData_result()[C:\FlexProjects\Resources\Resources.mxml:320]
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.rpc.http.mxml::HTTPService/ http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\dev\enterprise_gmc\frame works\mx\rpc\http\mxml\HTTPService.as:242
      at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\dev\enterprise_gmc\framewor ks\mx\rpc\AbstractInvoker.as:167
      at mx.rpc::Responder/result()[C:\dev\enterprise_gmc\frameworks\mx\rpc\Responder.as:48]
      at mx.rpc::AsyncRequest/acknowledge()[C:\dev\enterprise_gmc\frameworks\mx\rpc\AsyncRequest.a s:82]
      at DirectHTTPChannel.as$135::DirectHTTPMessageResponder/completeHandler()[C:\dev\enterprise_ gmc\frameworks\mx\messaging\channels\DirectHTTPChannel.as:359]
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/flash.net:URLLoader::onComplete()

      Is XML data represented differently in Flex 2 than it was in Beta 3, such that I can no longer cast it to an ArrayCollection? What do I need to do to get this to succeed?
        • 1. Re: Array collections vs. HTTPService
          leotemp Level 1
          I had that happen to and found for whatever reason i was needing the aray util before i didnt need it now, dont ask me why I literally draw pictures for a living but desperatly want to learn flex in and out. any way you can list a sample of you xml your parsing and the component or function using it?

          if xml is like this
          <group>
          <name>Mr Smelly</name>
          <smell>Smelly</smell>
          <name>Stank alot</name>
          <smell>stanky</smell>
          </group>
          and you say want an xmlList(behaves like a collection?) of all the "smells" then you would use a dataprovider of HTTPserviceName.lastResult.group.smell hope that helps.
          • 2. Re: Array collections vs. HTTPService
            Kwooda Level 1
            If you notice in my original post, I am attempting to extract the results of the HTTPService call (xmlData.lastResult.purpose.resource) into an ArrayCollection. This code has been untouched and unchanged (along with the XML file it is loading) since beta 3, and now it simply doesn't work in the release version. Can I not extract the results into an ArrayCollection directly like this, or is there some other way to do it now?
            • 3. Re: Array collections vs. HTTPService
              ntsiii Level 3
              Ok, I think this is that "makeObjectsBindable" setting. It is true in the release by default, and setting it to false should fix this.

              makeObjectsBindable is a property of the HTTPService class. Set it and let us know if that was it.

              Tracy
              • 4. Array collections vs. HTTPService
                Kwooda Level 1
                Excellent! That did the trick (though now I'm getting a permission denied error, in lines 4 and 12, from the HTML wrapper...???).