2 Replies Latest reply on Sep 13, 2007 3:50 PM by chris.huston.t10

    XML Help

    Whitetimer Level 1
      Hi All

      I have this an a child component and for some reason it wont work ... any thoughts ?

      quote:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml"
      horizontalScrollPolicy="off"
      verticalScrollPolicy="off"
      width="680"
      height="100%"
      label="Training" creationComplete="wtCoursesHTTP.send()">

      <!-- Page Script -->

      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.rpc.events.ResultEvent;

      [Bindable]
      public var m_ParentRef:Object;

      [Bindable]
      private var coursesData:ArrayCollection;

      private function setParentRef( p_Ref:Object ) : void {

      m_ParentRef = p_Ref;

      }

      private function compNav( mainVS:int, childVS:int ) : void {

      m_ParentRef.appMainBodyVS.selectedIndex = mainVS;
      m_ParentRef.appMainBodyVS.selectedChild.vs.selectedIndex = childVS;

      }

      private function wtcRH(event:ResultEvent) : void {

      coursesData = event.result.Courses.level as ArrayCollection ;

      }


      ]]>
      </mx:Script>

      <!-- HTTP Service Calls -->

      <mx:HTTPService id="wtCoursesHTTP" url="./assets/xml/wtcourses.xml" result="wtcRH(event)" resultFormat="array" />

      <!-- Navigation -->

      <!-- Main View -->

      <mx:ComboBox dataProvider="{coursesData}" labelField="@name" />

      <mx:Tile direction="horizontal">

      <mx:Repeater id="coursesRep" dataProvider="{coursesData}">

      <mx:Button height="200" width="200" label="{String(coursesRep.currentItem.name)}" />

      </mx:Repeater>

      </mx:Tile>


      </mx:VBox>



      XML is

      <Courses>
      <level>
      <name></name>
      <title></title>
      <outline></outline>
      <cost></cost>
      <duration></duration>
      <upgrades></upgrades>
      </level>
      </Courses>

      I have something similar within anothe child component and that works fine, but this does not ... grrrrr

      Many thanks
        • 1. Re: XML Help
          Anakin_Jay
          I've found combo boxes only work for me if I only have one option in the xml.

          so like this:
          ---------------------------------------
          <Courses>
          <Level> Name </Level>
          </Courses>
          -----------------------------------------

          and it's a pain in my rear 'cause I can't associate any of other options (in your case the title.. cost.. etc.) with it flex side. I have to associate it Server side.

          If I'm filling out the rest of my flex app based off the drop down, I have to have a second httprequest that sends the value of the combobox as a parameter and returns the rest of those options in another xml layed out like you have yours there.

          Doubt thats the best way to do it, but thats the only way I've gotten it to work.
          • 2. Re: XML Help
            chris.huston.t10 Level 3
            First thought is to change your labelField assignment to:
            labelField="name"

            The '@' operator is used to access xml attributes, not values.

            I also would suggest setting your resultFormat to e4x and just working with XML or XMLList:

            <mx:Script>
            <![CDATA[
            import mx.rpc.events.ResultEvent;

            [Bindable]
            public var m_ParentRef:Object;

            [Bindable]
            private var coursesData:XMLList;

            private function setParentRef( p_Ref:Object ) : void {

            m_ParentRef = p_Ref;

            }

            private function compNav( mainVS:int, childVS:int ) : void {

            m_ParentRef.appMainBodyVS.selectedIndex = mainVS;
            m_ParentRef.appMainBodyVS.selectedChild.vs.selectedIndex = childVS;

            }

            private function wtcRH(event:ResultEvent) : void {

            coursesData = event.result.level as XMLList;

            }


            ]]>
            </mx:Script>

            <!-- HTTP Service Calls -->

            <mx:HTTPService id="wtCoursesHTTP" url="wtcourses.xml" result="wtcRH(event)" resultFormat="e4x" />

            <!-- Navigation -->

            <!-- Main View -->
            <mx:VBox>
            <mx:ComboBox dataProvider="{coursesData}" labelField="name" />

            <mx:Tile direction="horizontal">

            <mx:Repeater id="coursesRep" dataProvider="{coursesData}">

            <mx:Button height="200" width="200" label="{String(coursesRep.currentItem.name)}" />

            </mx:Repeater>

            </mx:Tile>

            Vygo