months, days, stars… ugh. 04.30.10
I’m putting this here for two reasons: 1. This is the second time I’ve needed to have data about how many days preceded each month. (e.g. there are 304 days before Oct. 1) and 2. I’m curious if there’s an easier way to do something like this. When I was working on a countdown clock there was a lot of modulo operators and the results were much cleaner than below. Since the number of days in a month varies (unlike the number of minutes in an hour) I couldn’t think of a way.
Basically, there’s a slider (mySlider) that is controlling the rotation of a planisphere. (dial_mc) We want to give users information (mymonth, myday) about what night sky they’re looking at since the planisphere is almost impossible to read. (it was made in 1780…) You can adjust the planisphere for different times of day, but we’re only interesting in giving the user midnight. myday and mymonth get displayed in dynamic text boxes.
onClipEvent(enterFrame){
this._rotation = ((_root.mySlider.ratio)*-1); //dial_mc (this) needs to spin CCW
var mymonth;
var myday = 0;
if (_root.mySlider.ratio <= 31){
_root.mymonth = “Jan”;
_root.myday = Math.round(_root.mySlider.ratio);
//since the slider will start at 0 we want to make that 1
if ((Math.round(_root.mySlider.ratio)) == 0){
_root.myday = 1;
}
}
else if (_root.mySlider.ratio <= 59 && _root.mySlider.ratio >= 31){
_root.mymonth = “Feb”;
_root.myday = (Math.round(_root.mySlider.ratio) – 31);
}
else if (_root.mySlider.ratio <= 90 && _root.mySlider.ratio>=59){
_root.mymonth = “March”;
_root.myday = (Math.round(_root.mySlider.ratio) – 59);
}
else if (_root.mySlider.ratio <= 120 && _root.mySlider.ratio>=90){
_root.mymonth = “April”;
_root.myday = (Math.round(_root.mySlider.ratio) – 90);
}
else if (_root.mySlider.ratio <= 151 && _root.mySlider.ratio>=120){
_root.mymonth = “May”;
_root.myday = (Math.round(_root.mySlider.ratio) – 120);
}
else if (_root.mySlider.ratio <= 181 && _root.mySlider.ratio>=151){
_root.mymonth = “June”;
_root.myday = (Math.round(_root.mySlider.ratio) – 151);
}
else if (_root.mySlider.ratio <= 212 && _root.mySlider.ratio>=181){
_root.mymonth = “July”;
_root.myday = (Math.round(_root.mySlider.ratio) – 181);
}
else if (_root.mySlider.ratio <= 243 && _root.mySlider.ratio>=212){
_root.mymonth = “Aug”;
_root.myday = (Math.round(_root.mySlider.ratio) – 212);
}
else if (_root.mySlider.ratio <= 273 && _root.mySlider.ratio>=243){
_root.mymonth = “Sep”;
_root.myday = (Math.round(_root.mySlider.ratio) – 243);
}
else if (_root.mySlider.ratio <= 304 && _root.mySlider.ratio>=273){
_root.mymonth = “Oct”;
_root.myday = (Math.round(_root.mySlider.ratio) – 273);
}
else if (_root.mySlider.ratio <= 334 && _root.mySlider.ratio>=304){
_root.mymonth = “Nov”;
_root.myday = (Math.round(_root.mySlider.ratio) – 304);
}
else if (_root.mySlider.ratio <= 365 && _root.mySlider.ratio>=334){
_root.mymonth = “Dec”;
_root.myday = (Math.round(_root.mySlider.ratio) – 334);
}
}
month data:
Jan: 31
Feb: 59
Mar: 90
Apr: 120
May: 151
June: 181
July: 212
Aug: 243
Sep: 273
Oct: 304
Nov: 334
Dec: 365
When the product of all this is approved and goes live, I’ll add a link here.


