This code is gathered mostly from random posts here and on other sites… it’s probably dirty code and not ideal for some of you flash experts.
Anyhow, anyone who wants to use this or make it better it feel free. Just post your workings.
I’ll be adding XML to this shortly.
Dowload the .fla if you want to see it in action
if(nM == 0){
var nM:int = 0;
}
var currentDate:Date = new Date();
var monthsOfYear:Array = new Array(“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”);
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{
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 = “square”+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.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);
}
function tab1Out (e:Event):void{
e.currentTarget.gotoAndStop(1);}
}