Dynamic layout formula

hi. i’m trying to dynamically layout a calendar using actionscript and i’m no good at determining algorithms to quickly and efficiently lay things out. i was hoping for a little help with this one, please.

what i want to do is set it up per the image attached:

  • where there are 7 columns and a varying number of rows.

  • the top row has the 2 arrows and the month and year display.

  • the second row has all the day headings, i.e. S, M, T, W, R, F, S

  • and the rest of the rows will have the dates.

how do i come up with a nice clean formula to calculate the positions so all these elements align??

thanks. fumeng.