March 21st, 2007
BadFlexBad Entry for Wed., March 2007
Alright, here's one for the "what were they thinking?" category...when creating dates, the Date() constructor takes in a zero indexed month but not a zero indexed day, huh?
XML:
-
</code>
-
-
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml">
-
creationComplete="ccInit()"
-
layout="vertical">
-
<mx:script>
-
<!--[CDATA[
-
private var dateIChose:Date;
-
private function ccInit():void
-
{
-
// When passing in the month parameter, keep in mind it's zero indexed...
-
dateIChose = new Date(2007,3,3);
-
}
-
private function populateDateField(p_evt:MouseEvent):void
-
{
-
// Check out the DateField being set to April...
-
my_df.selectedDate = dateIChose;
-
}
-
]]-->
-
</mx:script></mx:application>
-
-
<mx:datefield id="my_df"></mx:datefield>
-
-
<mx:text id="description_txt">
-
width="200">
-
<mx:text>
-
Click on the button to
-
populate the DateField with
-
2007 for the year,
-
3 for the month,
-
and 3 for the day.
-
You think it'll set to March right?
-
</mx:text>
-
</mx:text>
-
-
<mx:button id="setDate_btn">
-
label="populate DateField"
-
click="populateDateField(event)"/>
-
</mx:button>

