1 Reply Latest reply on Oct 5, 2007 2:48 PM by Gregory Lafrance

    How to set background color for selected days in DateChooser

    Giribabums Level 1
      How to set background color for selected days. I created checkbox for each day [Son,Mon,Tue,Wed,Thu,Fri,Sat] and a DateChooser, I want to change the background color for the selected day when i click on a button after selecting the desired checkboxs [ monthly wise/yearly wise]
      Thanks in advance
        • 1. Re: How to set background color for selected days in DateChooser
          Gregory Lafrance Level 6
          There is no button involved in the following code, but it may be of use to you:

          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="init()">
          <mx:Script>
          <![CDATA[
          private var origColor:uint;
          private function init():void {
          origColor = dc.getStyle("selectionColor");
          }

          public function setBackGrdColors(newColor:uint):void {
          dc.setStyle("selectionColor", origColor);
          if(dc.selectedDate){
          var dayOfWeek:Number = dc.selectedDate.day;
          }
          else{
          return;
          }
          switch(dayOfWeek) {
          case 0:
          if(sun.selected)
          dc.setStyle("selectionColor", newColor);
          break;
          case 1:
          if(mon.selected)
          dc.setStyle("selectionColor", newColor);
          break;
          case 2:
          if(tue.selected)
          dc.setStyle("selectionColor", newColor);
          break;
          case 3:
          if(wed.selected)
          dc.setStyle("selectionColor", newColor);
          break;
          case 4:
          if(thu.selected)
          dc.setStyle("selectionColor", newColor);
          break;
          case 5:
          if(fri.selected)
          dc.setStyle("selectionColor", newColor);
          break;
          case 6:
          if(sat.selected)
          dc.setStyle("selectionColor", newColor);
          break;
          default:
          break;
          }
          }
          ]]>
          </mx:Script>
          <mx:VBox horizontalAlign="center" verticalGap="20">
          <mx:DateChooser id="dc" textAlign="left" change="setBackGrdColors(cellColor.selectedColor)"/>
          <mx:HBox width="100%" horizontalAlign="center">
          <mx:CheckBox id="sun" label="Sun"/>
          <mx:CheckBox id="mon" label="Mon"/>
          <mx:CheckBox id="tue" label="Tue"/>
          <mx:CheckBox id="wed" label="Wed"/>
          </mx:HBox>
          <mx:HBox width="100%" horizontalAlign="center">
          <mx:CheckBox id="thu" label="Thu"/>
          <mx:CheckBox id="fri" label="Fri"/>
          <mx:CheckBox id="sat" label="Sat"/>
          </mx:HBox>
          <mx:HBox width="300" horizontalAlign="center">
          <mx:Label text="Background Color" />
          <mx:ColorPicker id="cellColor" selectedColor="#FF00FF"/>
          </mx:HBox>
          </mx:VBox>
          </mx:Application>