3 Replies Latest reply on Oct 13, 2008 10:02 AM by Newsgroup_User

    Suggestions to mark days off in a month

    miglara

      Hi,

      As part of this app I need to display a 31-day month which starts on Sunday.
      The user will enter a day between 1 and 31; all the days before that date should be replaced by an "X".
      For example, if the user enters "20", all days for weeks 1 and 2 should be "X" as well as 5 days for week 3.
      While this is very simple to accomplish on a scripting language, I'm having a difficult time to do it in Flex and I was wondering if there is some easy way to do it.
      To display the days per week, I've defined 5 arrays that go from 1 to 7, 8 to 14, and so on.
      Then, I'm using 5 repeaters, each associated to one of these arrays. This displays the month correctly but I'm not sure how to replace the numbers by "X" once the user enters the date.

      Could someone please describe what would be the best approach to accomplish this task? Should I create a model for the 31 days of the month or is there an easier looping structure to do it?

      Here is the pseudoscript:

      var dateSelected:int = 17;

      for (i:int=1; i < 31; i++) {

      if ( i mod 7 = 0) print "<br>";
      if ( i < dateSelected ) {
      print "X";
      } else {
      print i + " ";
      }
      }

      Thank you!
        • 1. Re: Suggestions to mark days off in a month
          Level 7

          "miglara" <webforumsuser@macromedia.com> wrote in message
          news:gcth9r$s3g$1@forums.macromedia.com...
          > Hi,
          >
          > As part of this app I need to display a 31-day month which starts on
          > Sunday.
          > The user will enter a day between 1 and 31; all the days before that date
          > should be replaced by an "X".
          > For example, if the user enters "20", all days for weeks 1 and 2 should be
          > "X"
          > as well as 5 days for week 3.
          > While this is very simple to accomplish on a scripting language, I'm
          > having a
          > difficult time to do it in Flex and I was wondering if there is some easy
          > way
          > to do it.
          > To display the days per week, I've defined 5 arrays that go from 1 to 7, 8
          > to
          > 14, and so on.
          > Then, I'm using 5 repeaters, each associated to one of these arrays. This
          > displays the month correctly but I'm not sure how to replace the numbers
          > by
          > "X" once the user enters the date.
          >
          > Could someone please describe what would be the best approach to
          > accomplish
          > this task? Should I create a model for the 31 days of the month or is
          > there an
          > easier looping structure to do it?
          >
          > Here is the pseudoscript:
          >
          > var dateSelected:int = 17;
          >
          > for (i:int=1; i < 31; i++) {
          >
          > if ( i mod 7 = 0) print "<br>";
          > if ( i < dateSelected ) {
          > print "X";
          > } else {
          > print i + " ";
          > }
          > }
          >
          > Thank you!

          You might find this example helpful in looking at an approach. Look at how
          the background graphic is added dynamically to the calendar page for today.

          http://flexdiary.blogspot.com/2008/09/groupingcollection-example-featuring.html

          HTH;

          Amy


          • 2. Re: Suggestions to mark days off in a month
            miglara Level 1
            Thanks a lot, Amy! The example you mention is really helpful!
            • 3. Re: Suggestions to mark days off in a month
              Level 7

              "miglara" <webforumsuser@macromedia.com> wrote in message
              news:gcvt3h$pnc$1@forums.macromedia.com...
              > Thanks a lot, Amy! The example you mention is really helpful!

              You're welcome :-)