5 Replies Latest reply on May 17, 2007 2:03 PM by scooter5791

    Reading local text file

    compubrook
      Hi,

      I am trying touse an HTTPService to read in an XML file. The end result is going to be a section of text that changes every 8 senconds or so.

      The xml file is:
      <?xml version="1.0" ?>
      <text>
      <co2>hi there</co2>
      <co2>bye for now</co2>
      </text>

      And my Flex looks like this:
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute"
      viewSourceURL="srcview/index.html"
      initialize="co2facts.send()"
      >
      <mx:HTTPService id="co2facts" url="CO2factdata.xml" result="resultHandler(event)"/>


      <mx:Canvas width="40%" height="60%" right="0">

      <mx:Text text="{CO2Text.getItemAt(0).co2}" textAlign="center">

      </mx:Text>
      </mx:Canvas>

      And my AS looks like this:
      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      [Bindable]
      public var CO2Text:ArrayCollection;

      private function resultHandler(event:ResultEvent):void
      {
      CO2Text = event.result.text;
      }
      ]]>
      </mx:Script>


      When this runs I get an error!

      TypeError: Error #1034: Type Coercion failed: cannot convert mx.utils::ObjectProxy@47c1941 to mx.collections.ArrayCollection.
      at Kiosk/::resultHandler()
      at Kiosk/__co2facts_result()
      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()
      at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::resultHandler()
      at mx.rpc::Responder/result()
      at mx.rpc::AsyncRequest/acknowledge()
      at ::DirectHTTPMessageResponder/completeHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/flash.net:URLLoader::onComplete()


      I know I'm missing some stupid little thing - anyone know wha it is???