单击日历时跟踪当天的名称

时间:2015-11-19 04:27:26

标签: actionscript-3 date calendar

我已经下载了一个我已经修改过的日历的免费代码。

目前,当我点击日历上的方块时,"跟踪"告诉我日期和#34; 2015年11月19日"。

我希望能够追踪一周中的某一天。 (如2015年11月19日星期四)。

这是我的代码:

    if(nM == 0){
    var nM:int = 0;
}

var monthsOfYear:Array = new Array("Janvier", "February", "March", "April", "May", "June", "July", "August", "September", "October", "novembre", "decembre");
var daysOfMonths:Array = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

var addMonths:int = (currentDate.getMonth()+nM);
var myDate = new Date(currentDate.getFullYear(), currentDate.getMonth()+nM);//provided by Andrei Firoiu
var startDay = myDate.getDay(); 

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

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

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

                        }

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

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

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

        calendar.month_txt.text = monthsOfYear[addMonths];
        calendar.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);
            mySharedObject.data.theDate = e.currentTarget.name +" "+ monthsOfYear[addMonths]+" "+myDate.fullYear;
            trace(mySharedObject.data.theDate);
            mySharedObject.data.theCity = "Noumea";
            }

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

Thx求助,

1 个答案:

答案 0 :(得分:0)

这经常被问到,搜索应该显示许多答案。但是,您可以使用getDay()

vexpand