4 Replies Latest reply on Sep 9, 2011 2:28 PM by kglad

    Date Chooser - odd behaviour ? !

    Tony Heagren Level 1

      Hi all,

       

      I'm playing around with a booking system and thought a date chooser might suit my needs.

      Each "set" button on the stage opens (makes visible) the same DateChooser component and when the date is

      clicked timeline code on frame 1 delivers the data to a dynamic text box (code at the end of this post).

       

      My issue is when the date is clicked in the "calendar" the info is delivered to a dynamic text box and it displays

      in one of two apparently random formats (see picture) i.e. with or with out "GMT+0100" on the end of the string.

       

      So my question is how do I manage / manipulate / control the formatting of the data ?
      I ideally want it presented like this: Saturday 27th September 2011  (with NO time included).

       

      NB - the "set" on the left and the "am" on the right are just buttons and graphics on my stage.

      dates2.jpg

       

      All and any help / tips / links tutorials much apprecited.

       

      Best wishes

      Tony

       

       

      "set" button code:

      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

      on (release) {
          calendar_dc._visible = 1
          quando = 1;
      }

       

       

       

      timeline (frame1) code:

      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

       

      var dcListener:Object = new Object();
      dcListener.change = function(evt_obj:Object) {
      var thisDate:Date = evt_obj.target.selectedDate;

       

      if (_root.quando == 1) {
          date1 = thisDate;
      } else if (_root.quando == 2) {
          date2 = thisDate;
      } else if (_root.quando == 3) {
          date3 = thisDate;
      } else if (_root.quando == 4) {
          date4 = thisDate;
      } else if (_root.quando == 5) {
          date5 = thisDate;
      };

      calendar_dc._visible = 0;
      };

      calendar_dc.addEventListener("change", dcListener);

        • 1. Re: Date Chooser - odd behaviour ? !
          kglad Adobe Community Professional & MVP

          use:_ _ _ _ _ _ _ _ _ _ _ _ _

          var monthA:Array=["Jan","Feb","Mar",etc..];  // use whatever format you want

          var dcListener:Object = new Object();
          dcListener.change = function(evt_obj:Object) {
          var d:Date = evt_obj.target.selectedDate;

          var thisDate:String=d.getDay()+" "+monthA[d.getMonth()]+" "+d.getDate();

           

          if (_root.quando == 1) {
              date1 = thisDate;
          } else if (_root.quando == 2) {
              date2 = thisDate;
          } else if (_root.quando == 3) {
              date3 = thisDate;
          } else if (_root.quando == 4) {
              date4 = thisDate;
          } else if (_root.quando == 5) {
              date5 = thisDate;
          };

          calendar_dc._visible = 0;
          };

          calendar_dc.addEventListener("change", dcListener);

          • 2. Re: Date Chooser - odd behaviour ? !
            Tony Heagren Level 1

            Hi,

             

            thanks for helping - I tried this (code below) and got a syntax error 

            for line 1 (the aray) - any ideas ?

             

            Best wishes

            Tony

             

             

            var monthA:Array =

            ["January","February","March","April","May","June","July","August","Sept

            ember","October","November","December"];

            // use whatever format you want

            var dcListener:Object = new Object();

            dcListener.change = function(evt_obj:Object) {

            var d:Date = evt_obj.target.selectedDate;

            var thisDate:String=d.getDay()" "monthA[d.getMonth()]" "d.getDate();

            // MY version !

            //var dcListener:Object = new Object();

            //dcListener.change = function(evt_obj:Object) {

            // var thisDate:Date = evt_obj.target.selectedDate;

             

            if (_root.quando == 1) {

                 date1 = thisDate;

            } else if (_root.quando == 2) {

                 date2 = thisDate;

            } else if (_root.quando == 3) {

                 date3 = thisDate;

            } else if (_root.quando == 4) {

                 date4 = thisDate;

            } else if (_root.quando == 5) {

                 date5 = thisDate;

            };

             

            calendar_dc._visible = 0;

            };

            calendar_dc.addEventListener("change", dcListener);

            • 3. Re: Date Chooser - odd behaviour ? !
              Tony Heagren Level 1

              Scratch that - fixed it with exactly your code.

               

              Must have been some random white space from the cut and paste.

               

              Thanks again.

               

              Tony

              • 4. Re: Date Chooser - odd behaviour ? !
                kglad Adobe Community Professional & MVP

                you're welcome.