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:
  1. </code>
  2.  
  3. <mx:application xmlns:mx="http://www.adobe.com/2006/mxml">
  4. creationComplete="ccInit()"
  5. layout="vertical"&gt;
  6. <mx:script>
  7. <!--[CDATA[
  8. private var dateIChose:Date;
  9. private function ccInit():void
  10. {
  11. // When passing in the month parameter, keep in mind it's zero indexed...
  12. dateIChose = new Date(2007,3,3);
  13. }
  14. private function populateDateField(p_evt:MouseEvent):void
  15. {
  16. // Check out the DateField being set to April...
  17. my_df.selectedDate = dateIChose;
  18. }
  19. ]]-->
  20. </mx:script></mx:application>
  21.  
  22. <mx:datefield id="my_df"></mx:datefield>
  23.  
  24. <mx:text id="description_txt">
  25. width="200"&gt;
  26. <mx:text>
  27. Click on the button to
  28. populate the DateField with
  29. 2007 for the year,
  30. 3 for the month,
  31. and 3 for the day.
  32. You think it'll set to March right?
  33. </mx:text>
  34. </mx:text>
  35.  
  36. <mx:button id="setDate_btn">
  37. label="populate DateField"
  38. click="populateDateField(event)"/&gt;
  39. </mx:button>

Click here to run the code

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Upcoming Talks





A Book I Helped Write



Community


Ignite Denver Committee

Categories

Credits