Monday, December 11, 2006

Flex 2 dateChooser Component

If you've done much work with the dateChooser component in Flex 2 you know that it can be a little restrictive. I was recently working on an app where I wanted to load a list of dates from an XML file and somehow identify that those dates were clickable on the calendar. Turns out the only way to do this is to disable all of the other dates. I ended up dynamically building an array of start and end dates to pass to the disabledRanges method of the dateChooser component. The code is below. This may be obvious to many of you but it caused me a great deal of pain, one important thing to note is to be sure that the elements of your array are Date objects, not strings. Strings won't work....believe me.

The only input for the function is an array collection containing the dates that you want ENABLED.


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;
}


***UPDATE***
I received a comment recently asking for a sample of the XML used in the example above. I've included a snippet here.

<?xml version="1.0" encoding="utf-8"?>
<calendar>
<calItem>
<date>1/7/2007</date>
<milestone>Dad's Birthday</milestone>
<time></time>
<location></location>
<notes>Don't forget to pickup the balloons and the cake at the store before 5:00 on Friday.</notes>
</calItem>
<calItem>
<date>12/6/2006</date>
<milestone>Christmas Party</milestone>
<time>7:00pm</time>
<location>The Wave Room</location>
<notes></notes>
</calItem>
</calendar>

Tuesday, November 28, 2006

YouTube Going Mobile

Another exciting advancement on the mobile front from Verizon.

BBC NEWS | Technology | YouTube moves to the small screen

Saturday, June 03, 2006

Valleyschwag 2 Pic

So here's what came in my first shipment from Valleyschwag...not bad. I can't wait to see what next month brings!

  Posted by Picasa

Friday, June 02, 2006

My First Valleyschwag Shipment!

So yesterday I received my first shipment of goodies from Valleyschwag. I was qutie excited (I've always been a sucker for schwag). It came with some pretty cool stuff and of course the signature Valleyschwag burlap bag. The highlight was probably the MoveableType t-shirt and wrench. I'll try to post a couple of pictures soon.

Sunday, May 28, 2006

MS 150

I decided to join the office team in the MS 150 bike tour this year. I realize most of you don't know me from Adam but if you'd like to pledge me and support a teriffc cause I'd certainly appreciate it. Just click the link below and search for Tim Todish. Thanks!

Epledge

Friday, April 07, 2006

Tabs Launched on Netvibes

I saw a post earlier in the week about this being in beta but it appears that they have added it to the live site now. Very cool :)

Netvibes

Wednesday, April 05, 2006

gotoAndLearn()

With my buddy Joe leaving to go to knoware last week I've had to dive back into the world of Flash development -- I've been away for a while :(

Anyway, I stumbled accross this site last week while searching a forum, gotoAndLearn.com. It is a great resource of easy to following Flash tutorials done with Flash Video. Perfect for someone like me who learns best by watching someone else.