3 Replies Latest reply on Feb 15, 2008 3:49 AM by Sreenivas R

    DateChooser with external xml

    Tobias Bergström
      Im a beginner with Flex.

      How do I connect an external xml to a DateChooser so every time a date is picked a value/or text (different for different dates) from the xml is passed into a textArea.

      In this case I want a value of "50" to be passed to the the textArea for every day of the week exept for saturdays surtain months when the value is "80".

      Please show with whole code since I'm rather new to this.

      Thanks in advance!
        • 1. Re: DateChooser with external xml
          Sreenivas R Adobe Employee
          Hope he following sample helps !

          quote:


          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">

          <mx:XMLList id="statusData" >
          <day name="Saturday" value="10" />
          <day name="Sunday" value="20" />
          <day name="Monday" value="30" />
          <day name="Tuesday" value="40" />
          <day name="Wednesday" value="50" />
          <day name="Thursday" value="60" />
          <day name="Friday" value="70" />

          </mx:XMLList>

          <mx:Script>
          <![CDATA[
          private var weekDayNames =
          [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ];

          ]]>
          </mx:Script>

          <mx:DateChooser id="dateChooser" />

          <mx:TextInput id="status"
          text="{statusData.(@name == weekDayNames[dateChooser.selectedDate.getDay()]).attribute('value').toString()}"/>

          </mx:Application>

          • 2. Re: DateChooser with external xml
            Tobias Bergström Level 1
            I'm very greatful Sreenivas,
            Nice sollution that will be useful for me later on. If I new AS i could probably go myself from here.
            However, for this application I think I need to get the xml through an ArrayCollection and HTTPservices. Since the weekdays "values" varies over the year. (This will result in a big xml file with every day seperatet. Not a very neet solution maybe).

            How do I have the dateChooser calling xml through an ArrayCollection (not with the "dataProvider" i suppose) and returning different values for different days to a textArea

            Big thanks in advance!
            • 3. Re: DateChooser with external xml
              Sreenivas R Adobe Employee
              The statusData in my example can be any statusData:XMLList variable which you can populate using a HTTPService or DataService.

              I am sure you will find samples as to how to fetch a XML file using those services and convert it to a XMLLIst.

              It can't be a ArrayCollection because the e4x syntax I have used for binding may not work for it.