0 Replies Latest reply on Aug 23, 2012 11:35 AM by RedLabsSA

    Flex changes in a Spark DropDownList

    RedLabsSA

      New with flex, and need some advice. See the following code i got from a blog:

       

       

          <?xml version="1.0"?>

          <!-- http://blog.flexexamples.com/2009/04/09/determining-when-the-selected-item-changes-in-a-sp ark-dropdownlist-control-in-flex-gumbo/ -->

          <s:Application name="Spark_DropDownList_change_test"

              xmlns:fx="http://ns.adobe.com/mxml/2009"

              xmlns:s="library://ns.adobe.com/flex/spark"

              xmlns:mx="library://ns.adobe.com/flex/mx">

       

          <fx:Script>

              <![CDATA[

                  import spark.events.IndexChangeEvent;

       

                  protected function dropDownList_changeHandler(evt:IndexChangeEvent):void {

                      lbl.text = "You selected " + dropDownList.selectedItem.team;

                  }

              ]]>

          </fx:Script>

       

          <fx:Declarations>

              <s:ArrayList id="arrList">

                  <fx:Object team="Los Angeles" name="Angels of Anaheim" />

                  <fx:Object team="Seattle" name="Mariners" />

                  <fx:Object team="Oakland" name="Athletics" />

                  <fx:Object team="Texas" name="Rangers" />

                  <fx:Object team="Cleveland" name="Indians" />

                  <fx:Object team="Detroit" name="Tigers" />

                  <fx:Object team="Minnesota" name="Twins" />

                  <fx:Object team="Chicago" name="White Sox" />

                  <fx:Object team="Kansas City" name="Royals" />

                  <fx:Object team="Boston" name="Red Sox" />

                  <fx:Object team="New York" name="Yankees" />

                  <fx:Object team="Toronto" name="Blue Jays" />

                  <fx:Object team="Baltimore" name="Orioles" />

                  <fx:Object team="Tampa Bay" name="Rays" />

                  <fx:Object team="Arizona" name="Diamondbacks" />

                  <fx:Object team="Colorado" name="Rockies" />

                  <fx:Object team="San Diego" name="Padres" />

                  <fx:Object team="Los Angeles" name="Dodgers" />

                  <fx:Object team="San Francisco" name="Giants" />

                  <fx:Object team="Chicago" name="Cubs" />

                  <fx:Object team="Milwaukee" name="Brewers" />

                  <fx:Object team="St. Louis" name="Cardinals" />

                  <fx:Object team="Houston" name="Astros" />

                  <fx:Object team="Cincinnati" name="Reds" />

                  <fx:Object team="Pittsburgh" name="Pirates" />

                  <fx:Object team="Philadelphia" name="Phillies" />

                  <fx:Object team="New York" name="Mets" />

                  <fx:Object team="Atlanta" name="Braves" />

                  <fx:Object team="Washington" name="Nationals" />

                  <fx:Object team="Florida" name="Marlins" />

              </s:ArrayList>

          </fx:Declarations>

       

          <s:VGroup horizontalCenter="0" top="10">

              <s:DropDownList id="dropDownList"

                      dataProvider="{arrList}"

                      labelField="team"

                      prompt="Please select a team..."

                      change="dropDownList_changeHandler(event);" />

              <s:Label id="lbl" />

          </s:VGroup>

       

      </s:Application>

       

      What I`m trying to do is get data from a XML file, and where the difference is selected the Lable`s will show the details for example:

       

       

      I have 2 people in the xml:

       

       

          <job>

            <clientName>First Names</clientName>

            <clientSurname>Surnames</clientSurname>

            <clientMobile>123456789</clientMobile>

            <clientAlternative>987654321</clientAlternative>

            <dateBooked>Thu Aug 23 00:00:00 GMT+0200 2012</dateBooked>

            <dateRequired>Fri Aug 31 00:00:00 GMT+0200 2012</dateRequired>

            <numItems>1</numItems>

            <itemType>PC Box Only</itemType>

            <clientComments>Wont Power up

          Problem loading windows</clientComments>

            <clientRequirements>format and re-install

          backup document</clientRequirements>

            <itemLable>WW01</itemLable>

            <itemNotes>Damage on front panel

          Damage on back panel</itemNotes>

          </job>

       

      Where from the "dropdownlist" I selected the first person, his details would appear in the "Lable" field (SEE CODE ABOVE).

       

       

      Help! :-)