4 Replies Latest reply on Jul 5, 2007 4:06 PM by ctzn99

    XMList & TabBar


      I'm using HTTPService to load tabs to my project and I have somethnig like that in data:XMLList

      <name>Article 1</name>
      <name>Article 2</name>

      And I need to use it as dataprovider in TabBar, but
      <mx:TabBar dataProvider="{data}" labelField="name" />

      (the same code works on DataGrid)

        • 1. Re: XMList &amp; TabBar
          What are you expecting each tab to be named?

          Article 1 | Article 2

          Like above? Then you probably want:
          <mx:TabBar dataProvider="{data.article}" labelField="name" />

          Hope that's what you're looking for:
          • 2. XMList &amp; TabBar
            3wl4k Level 1
            trace(data) shows that (data:XMLList):
            <name>Nazov clanku</name>
            <creation_datetime>2007-06-17 19:41:05</creation_datetime>
            <name>Nazov clankuNazov clankuNazov clanku</name>
            <creation_datetime>2007-06-21 14:46:47</creation_datetime>
            <name>Nic podstatne</name>
            <perex>rthbrxtgbnstrxhn xyxtykmxmjyzyjmnznfn</perex>
            <creation_datetime>2007-06-29 10:34:52</creation_datetime>

            There's also problem with binding:
            1 Data binding will not be able to detect changes to XMLList "article", need an XML instance. Main.mxml

            And finaly there's one more problem, with equipment:
            Error: ERROR: The dataProvider of 'articles_categories' must not contain objects of type flash.display.DisplayObject.
            at mx.controls::NavBar/set dataProvider()
            at MethodInfo-585()
            at Function/ http://adobe.com/AS3/2006/builtin::call()
            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 mx.binding::Binding/watcherFired()
            at mx.binding::Watcher/notifyListeners()
            at mx.binding::PropertyWatcher/eventHandler()
            at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
            at flash.events::EventDispatcher/dispatchEvent()
            at libs::Articles/dispatchEvent()
            at libs::Articles/set aList()
            at libs::Articles/DecodeXMLArticles()
            at mx.rpc.http::HTTPService/ http://www.adobe.com/2006/flex/mx/internal::processResult()
            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 would say, that the solution is to transform XMLList to array.... How to do that?
            • 3. Re: XMList &amp; TabBar
              3wl4k Level 1
              The sollution of that problem was simple function:

              public var mainCategoriesList:XMLList();
              public vat MainCategories:Array();


              public function LoadCategories( ):void
              MainCategories = new Array();
              articles_subcategories.selectedIndex = -1;
              for each( var data:Object in mainCategoriesList){
              MainCategories.push( {id:data.id, name:data.name});

              And the dataProvider in TabBar reffers to {MainCategories}... and it works.

              THX for all your help.
              • 4. Re: XMList &amp; TabBar
                ctzn99 Level 1
                Stick the attribute [Bindable] in front of your xml variable and there was a mistake in what i said

                should be:

                <mx:TabBar dataProvider="{data.article.name}" />

                then you don't need the function, just a little cleaner but at the end of the day, the same result so it doesn't really matter