4 Replies Latest reply on Sep 22, 2006 7:14 AM by KostyaS

    DateChooser / DateField selectedDate Problem

    Mike Kelp Level 1
      I am having some trouble with both the DateChooser and DateField components that I can't seem to explain nor workaround.

      The problem occurs when deselecting the currently selected date. If I do not set selectedDate programmatically, all works well, but the moment I set selectedDate via actionscript, the calendar begins to use the last programmatically set date any time it is deselected rather than null.

      To illustrate, try the following steps using example code attached:
      1) Select a date using the mouse...An alert box with the date you chose should appear
      2) Deselect the date by clicking it again...An alert box with the text "null" should appear (All is correct so far)
      3) Click the "Set Selected Date" button...09/19/2006 should become selected
      4) Deselect the date by clicking on 09/19/2006...An alert box should appear displaying the 19th still (This is the problem)
      5) Keep selecting and deselecting dates and you will see that the deselect now always reverts back to the 19th of September

      Example Code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;

      private function showDate() : void {
      if (testDate.selectedDate != null)
      Alert.show(testDate.selectedDate.toString());
      else
      Alert.show("null");
      }
      ]]>
      </mx:Script>
      <mx:DateChooser id="testDate" change="showDate();" />
      <mx:Button label="Set Selected Date"
      click="testDate.selectedDate = new Date(2006, 08, 20);" />
      </mx:Application>

      Thanks in advance,
      Mike Kelp
      EdomGroup