1 Reply Latest reply on Dec 11, 2007 12:28 AM by NicholasKoji

    Array collection from XML data

    NicholasKoji
      I am trying to retrieve dates from an XML file and then place them into an array collection. for some reason this does not work.

      my XML Code:
      http://pastebin.com/m2cca6634

      my Flex 2 Code:
      http://pastebin.com/m787053fa



      also my debug tool doesnt work......i get an error claiming that my current flash player
      C:\WINDOWS\system32\Macromed\Flash\Flash9d.ocx

      Flex Builder cannot locate the required debug version of the Flash Player. You may need to install the debug version of Flash Player 9.0 or reinstall Flex Builder. Do you want to try to debug with the current version?
        • 1. Re: Array collection from XML data
          NicholasKoji Level 1
          update on script, still cant get it to work but i was able to have the dateArray store the dates.

          quote:


          <?xml version="1.0" encoding="iso-8859-1"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="getAvailability.send()">


          <mx:HTTPService
          id="getAvailability"
          url=" http://www.allaboutthekick.com/flex/php/dates.xml"
          method="post"
          resultFormat="e4x"
          result="dateHandler(event)"
          showBusyCursor="true"
          useProxy="false">
          </mx:HTTPService>

          <mx:Script>
          <![CDATA[

          import mx.collections.ArrayCollection;
          import mx.rpc.events.ResultEvent;

          [Bindable]
          private var validDates:ArrayCollection;

          private function dateHandler(event:ResultEvent):void{
          var dateArray:Array = new Array();
          for each (var p:XML in event.result..day){
          var date:Date = new Date(p.@year,p.@month,p.@day);
          dateArray.push(date)
          }
          validDates = new ArrayCollection(dateArray);
          }




          private function setValidDates(validDates:ArrayCollection):void{
          var rangeArray:Array = new Array;
          var millisecondsPerDay:int = 1000 * 60 * 60 * 24;
          for(var i:Number = 0; i < validDates.length; i++){
          var startIndex:Number;
          if (i > 0){
          startIndex = (i-1);
          } else {
          startIndex = i
          }
          var startDate:Date = new Date(validDates[startIndex].getTime() + (1* millisecondsPerDay));
          var endDate:Date = new Date(validDates .getTime() - (1 * millisecondsPerDay));
          if(i == 0){ rangeArray.push({rangeStart:new Date("Jan 1 1906"),rangeEnd:new Date(endDate)});
          } else if(i != validDates.length && i != 0){
          rangeArray.push({rangeStart:new Date(startDate),rangeEnd:new Date(endDate)});
          }
          }
          startDate = new Date(endDate.getTime() + (2*millisecondsPerDay));
          rangeArray.push({rangeStart:new Date(startDate)});
          myCal.disabledRanges = rangeArray;
          }

          ]]>
          </mx:Script>
          <mx:DateChooser id="myCal"/>

          </mx:Application>
          quote: