nicholaskoji
12-09-2007, 10:18 PM
I am trying to impliment this script which allows for me to enable dates by disabling the dates that i dont want. My problem is it that it calls for , and quoting, " one important thing to note is to be sure that the elements of your array are Date objects, not strings. Strings won't work."
now i am importing my data from an XML as you can see in the HTTPService.
Example XML file:
<hotels>
<hotel>
<date>
<hotel>
<hotels>
<?xml version="1.0" encoding="iso-8859-1"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:HTTPService
id="getAvailability"
url="php/availability.php"
method="post"
resultFormat="e4x"
showBusyCursor="true"
useProxy="false">
</mx:HTTPService>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
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[i].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>
this script was found on:
http://tttechblog.blogspot.com/2006/12/flex-2-datechooser-component.html
now i am importing my data from an XML as you can see in the HTTPService.
Example XML file:
<hotels>
<hotel>
<date>
<hotel>
<hotels>
<?xml version="1.0" encoding="iso-8859-1"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:HTTPService
id="getAvailability"
url="php/availability.php"
method="post"
resultFormat="e4x"
showBusyCursor="true"
useProxy="false">
</mx:HTTPService>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
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[i].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>
this script was found on:
http://tttechblog.blogspot.com/2006/12/flex-2-datechooser-component.html