1 Reply Latest reply on Nov 4, 2007 8:31 AM by ntsiii

    Binding Remotely Obtained XML With Repeater

    estacado1
      I want to bind an XML that I get from the web service to a repeater. I need to wait for the call to return, then do further manipulations to the XML before the XML is in its final form and ready to be binded. The problem is that the XML doesn't exist yet when the app is launched. I think that is why there is a runtime error. Code:

      <mx:ArrayCollection id="modelStoryArray" source="{finalXML.story}"/>
      <mx:Repeater id="storyRepeater" dataProvider="{modelStoryArray}">
      <mx:Text text="{storyRepeater.currentItem.@title}" fontFamily="Verdana" fontSize="16" width="1000"/>
      </mx:Repeater>

      Runtime Error:
      TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@2743719 to Array.
      at MethodInfo-573()
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
      at mx.binding::Binding/::innerExecute()
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
      at mx.binding::Binding/execute()
      at _httpTestsWatcherSetupUtil/setup()
      at httpTests/initialize()
      at mx.managers::SystemManager/ http://www.adobe.com/2006/flex/mx/internal::childAdded()
      at mx.managers::SystemManager/::initializeTopLevelWindow()
      at mx.managers::SystemManager/::docFrameHandler()


      And when I try to bind the XML to a data model it gives a compile error:
      "data binding expressions not supported with attributes processed at compile time"
      Code of data model:
      <mx:Model id="displayXML" source="{finaXML}"/>

      How do I solve this?
        • 1. Re: Binding Remotely Obtained XML With Repeater
          ntsiii Level 3
          First, forget mx:Model. It is rarely of any value. Use mx:XML instead, if you want to load your data at compile time, as is what happens using source="".

          Then, declare a [Bindable] instance(global) variable typed as an XMLListCollection. In a creationComplete event thandler, assign the value of that variable. Bind your repeter dataProvider to it.

          the creationComplete handler would look something like:
          private function init():void
          _xlcData = new XMLListCollection(xmlDisplay.story);
          trace(_xlcData.toXMLString() ); //to make sure yo have the data you want.


          Tracy