4 Replies Latest reply on Apr 15, 2009 5:50 AM by alice_data

    Double Click on DateChooser Issues

    alice_data Level 1

      Hi,
         I am trying to accomplish the double click function on DateChooser and it seems like I am running into the issues of getting the date value of the date that has been double clicked. Currently, I am constantly getting the message that says Invalid Date.

       

        Below is the code, and I am suspecting that it has to do something with the event type of my function, but I am not entire sure.

       

      private function useDate2(eventObj:MouseEvent):void {
          
               if (eventObj.currentTarget.selectedDate == null) {   // Make sure selectedDate is not null.
                     //don't do a thing
                  }
                else {  //Access the Date object from the event object.  
                            
                  var date:String=eventObj.currentTarget.selectedDate.getDate();
                  var month:String= eventObj.currentTarget.selectedDate.getMonth();
                  var year:String= eventObj.currentTarget.selectedDate.getFullYear();           
                  wholeDate= new Date(year,month,date);
                  //I get an invalid date when I try to trace the value of this
                  trace(wholeDate.toDateString());
                  var xlc3:XMLListCollection = new XMLListCollection(searchResult..book.(@name == selectedName).appt.@type);
                  var xlc4:XMLListCollection = new XMLListCollection(searchResult..book.@name);
                  var xlc5:XMLListCollection = new XMLListCollection(searchResult..book.(@name == selectedName).appt.@date);
                  for each (var xml5:XML in xlc5) {
                         var real_date:Date = new Date(xml5.toString());
                          for each (var xml4:XML  in xlc4) {  
                      var schedule_name:Date= new Date(xml4.parent()..date);
                            trace (schedule_name.toDateString());
                         
                           if (schedule_name.toDateString() === wholeDate.toDateString()){
                              
                           }          
                           if (real_date.toDateString() === wholeDate.toDateString()) {    
                             trace(real_date.toDateString());
                             trace(xml5.parent().@type.toString());                    
                          }           //end if
                       }
                  }         //end for each xlc5
                     
            } //end the else statement        
         }

       

        private function calendar_create():void {
                   
                           dch = new DateChooser();                
                                  
                          //enable the double Click Enabled Property
                          dch.doubleClickEnabled = true;                 
                                                             
                          //enable the double Click Enabled Property

                          dch.addEventListener("doubleClick",useDate2);                                    

      }

       

       

      Can anyone please give me on some pointers on how I could get the date value of the double clicked item here?

      Thanks in advance.

       

      Alice

        • 1. Re: Double Click on DateChooser Issues
          Michael Borbor Level 4

          Hi Alice I took a look briefly to your code but I'll strongly recommend you inside your event listener to cast the event.currentTarget as DateChooser that could be the issue.

          1 person found this helpful
          • 2. Re: Double Click on DateChooser Issues
            alice_data Level 1

            Hi,

             

              Is it possible that you could show me an example on what the code of this might look like?

              It does not have to be the example of what I have here, since I am really new to using type casting with Flex and Actionscript.

             

            Thanks for your help.

             

            Alice

            • 3. Re: Double Click on DateChooser Issues
              Michael Borbor Level 4

              Sure Alice, hope this helps.

               

              trace(DateChooser(event.currentTarget).selectedDate.toString());
              
              • 4. Re: Double Click on DateChooser Issues
                alice_data Level 1

                Hi, Michael:

                 

                  Thanks for the example. I changed that bit of code and looks like the date is displaying properly now.

                 

                  private function useDate2(event:MouseEvent):void {
                    
                         if (event.currentTarget.selectedDate == null) {   // Make sure selectedDate is not null.
                               //don't do a thing
                            }
                          else {  //Access the Date object from the event object.  
                                      
                            var date:String=DateChooser(event.currentTarget).selectedDate.getDate().toString();
                            var month:String= DateChooser(event.currentTarget).selectedDate.getMonth().toString();
                            var year:String= DateChooser(event.currentTarget).selectedDate.getFullYear().toString();   
                                   
                            wholeDate= new Date(year,month,date);
                            trace(wholeDate.toDateString());        
                      
                      } //end the else statement        
                   }

                 

                Alice