dimanche 22 novembre 2015

Don't want the calendar begining by sunday

I've got a code that shows a calendar when I click on the icon. Unfortunately, the calendar is begining by Sunday. I would like to begin the week by Monday. Any idea how I can do that by modifing my code ?

    if(nM == 0){
    var nM:int = 0;
}
var thisDate:Date = new Date()
var monthsOfYear:Array = new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
var daysOfMonths:Array = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var myCalendarData:SharedObject = SharedObject.getLocal("theCalendar");
var addMonths:int = ( thisDate.getMonth()+nM);
var myDate = new Date( thisDate.getFullYear(),  thisDate.getMonth()+nM);//provided by Andrei Firoiu
var startDay = myDate.getDay(); 


    addEventListener(Event.ENTER_FRAME, onEnterFrame);
        function onEnterFrame(event:Event):void{
         month_txt.text = monthsOfYear[addMonths];
         year_txt.text =  " " + myDate.fullYear;
}

                       while (addMonths > 11) 
                        {
                            addMonths = addMonths - 12;

                        }
                        while (addMonths < 0) 
                        {
                            addMonths = addMonths + 12;

                        }

 lM_mc.addEventListener(MouseEvent.MOUSE_DOWN, onMouseClickEvent1);
    function onMouseClickEvent1(event:Event){
        nM = nM-1;
        removeChild(holder_txt);
            play();

         month_txt.text = monthsOfYear[addMonths];
         year_txt.text =  " " + myDate.fullYear;
  }                   

 nM_mc.addEventListener(MouseEvent.MOUSE_DOWN, onMouseClickEvent);
    function onMouseClickEvent(event:Event){
        nM = nM+1
        removeChild(holder_txt);
            play();

         month_txt.text = monthsOfYear[addMonths];
         year_txt.text =  " " + myDate.fullYear;
  }

function getDays(date:Date):uint {
return (myDate.getFullYear()%4 == 0 && myDate.getMonth() == 1 ? 29 : daysOfMonths[myDate.getMonth()]);
}

//-----------------------------
var myArray:Array = new Array();
//var spacing:int = 50;
var row:Number = 0;
var holder_txt:MovieClip = new MovieClip;
addChild(holder_txt);
holder_txt.x = 35;
holder_txt.y = 10;


//addChild(squares);

    for (var t:int = 0; t < getDays(myDate); t++) {
    myArray[t] = (t+1);
    var textNum:String = myArray[t];
    import box;
    var square:MovieClip = new box();
    holder_txt.addChild(square);
    square.name = textNum
    square.texter.text = textNum;
    square.x = (startDay) *75
    square.y = (row+1)*65
    startDay++;
        if(startDay >= 7){
            startDay = 0;
            row++;

        }

        square.mouseChildren = false;
        square.addEventListener(MouseEvent.CLICK, squareClicked);
        //square.addEventListener(MouseEvent.MOUSE_OVER, tab1Over);
        square.addEventListener(MouseEvent.MOUSE_OUT, tab1Out);
        //square.addEventListener(MouseEvent.MOUSE_DOWN,tab1Down);

        //function tab1Over (e:Event):void{
        //  e.currentTarget.play();
        //  trace(e.currentTarget.name +" "+ monthsOfYear[addMonths]+" "+myDate.fullYear);
        //  }
        function squareClicked (e:Event):void{
            e.currentTarget.play();
            trace(e.currentTarget.name +" "+ monthsOfYear[addMonths]+" "+myDate.fullYear);
            myCalendarData.data.theDateCal = e.currentTarget.name +" "+ monthsOfYear[addMonths]+" "+myDate.fullYear;
            myCalendarData.data.theCityCal= "Noumea";
            myCalendarData.flush();
            stage.dispatchEvent(new Event("calClicked"));


            }

        function tab1Out (e:Event):void{
            e.currentTarget.gotoAndStop(1);}
        }

Aucun commentaire:

Enregistrer un commentaire