4 Replies Latest reply on Apr 11, 2010 1:19 PM by EMelville

    XML Woes. Using XMLCollections, minor issue.

    EMelville

      Been pulling my hair out trying to get this little resultevent function to work:

       

      Neither this one:

      private function getXMLResult(evt:ResultEvent):void {    

           AmbientXMLCollection = GetXmlService.lastResult.image as XMLListCollection;

           testtxt.text = AmbientXMLCollection.toString();

          }

       

      or this one:

      private function getXMLResult(evt:ResultEvent):void {

          AmbientXMLCollection = new XMLListCollection(GetXmlService.lastResult.image);  

           testtxt.text = AmbientXMLCollection.toString();

          }

       

      Produces any effect. Except for an [object Object] in a textbox.

       

      The XML:

       

      <?xml version="1.0" encoding="utf-8"?>

      <gallery>

      <image username="agoodname"/>

      </gallery>


      The Service:

       

      <mx:HTTPService id="GetXmlService"

                  url="include/gallery.xml"

                  fault="getXMLFault(event);"

                  result="getXMLResult(event);"

                  showBusyCursor="true" />  

       

       

      The bottom line:

      Simply trying to get the xml "in full" to display in a text box. Can anyone help?

        • 1. Re: XML Woes. Using XMLCollections, minor issue.
          Radhakrishna Bhat Level 3

          If only XML String representation in textbox is required, inside getXMLresult function event.result is already an XML (if you set HTTPService's property resultFormat to e4x). Then use event.result.toXMLString()

           

          -Radhakrishna

          1 person found this helpful
          • 2. Re: XML Woes. Using XMLCollections, minor issue.
            EMelville Level 1

            Ok, perfect.

             

            Now I have:

             

            <mx:TileList id="tileList"

            dataProvider="{AmbientXMLCollection}"

            itemRenderer="CustomItemRenderer"

            columnCount="4"

            columnWidth="125"

            rowCount="2"

            rowHeight="150"

            verticalScrollPolicy="on"

            itemClick="tileList_itemClick(event);"  x="514" y="40"/>

             

            Any reason why the xml data won't populate in the tile list?

             

            Thanks Radhakrishna.

            • 3. Re: XML Woes. Using XMLCollections, minor issue.
              EMelville Level 1

              Even tried this.

               

              private function getXMLResult(evt:ResultEvent):void {

                   AmbientXMLCollection = GetXmlService.lastResult.image as XMLListCollection;

                   testtxt.text = AmbientXMLCollection.toString();

                   tileList.dataProvider = AmbientXMLCollection;

                  }

               

              Still nothing in the TileList yet. I must be missing something simple like the e4x in the httpservice.

               

              MXML:

               

              <mx:HTTPService id="GetXmlService"

              resultFormat="e4x"

                          url="include/gallery.xml"

                          fault="getXMLFault(event);"

                          result="getXMLResult(event);"

                          showBusyCursor="true" />  

               

              <mx:TileList id="tileList"

              itemRenderer="CustomItemRenderer"

              columnCount="4"

              columnWidth="125"

              rowCount="2"

              rowHeight="150"

              verticalScrollPolicy="on"

              itemClick="tileList_itemClick(event);"  x="514" y="40"/>

              • 4. Re: XML Woes. Using XMLCollections, minor issue.
                EMelville Level 1

                I got it. Binding to dataProvider="{GetXmlService.lastResult.image}" did it.