I have a flash mobile project where I need to determine the date of the next new or full moon that occurs after the current date. This application will not connect to the internet for information, so the logic must be done within Flash. Since this is a mobile project, I am looking for a Flash 4 level (Flash Lite 1.1 compatible) coding solution that is not too complex.
I found an algorithm that determines one of 8 lunar phases for the current date but I am not sure how helpful this will be for this particular problem. (I can modify this code for Flash 4 scripting)
This function seems to evaluate the current date based upon one of 8 positions within the lunar cycle. Is there a way to modify the function so that it evaluates for one of 29 positions in the lunar cycle (one for each day in the cycle)? Then I would know how may days away from current date the next new or full moon is.Code:function moon_phase(year,month,day) { /* calculates the moon phase (0-7), accurate to 1 segment. 0 = new moon. 1 = Waxing Crescent 2 = First Quarter 3 = Waxing Gibbous 4 = full moon. 5 = Waning Gibbous 6 = Last Quarter 7 = Waning Crescent */ d = day; if (month == 2) d += 31; else if (month > 2) d += 59+(month-3)*30.6+0.5; g = (year-1900)%19; e = (11*g + 29) % 30; if (e == 25 || e == 24) ++e; return ((((e + d)*6+5)%177)/22 & 7); }
Any suggestions on how to approach this problem?




Reply With Quote