Help w/Unit Formations?

Does anyone know a basic example for how to handle unit formations?
For example:

  • I’d like to draw 5 circles
  • then be able to move those 5 circles around the stage individually using a mouse click. Click on one circle, move it to a position. Click on another circle, move it to a different position, etc…
  • then select some circles out of the five. For example, I have 5 circles and only want to put 3 or 4 of them into a formation but leave the other remaining circles where they were moved last
  • then click a preferred button (buttons 1,2,3,4, or 5)
  • click on the stage and only those 4 circles arrange themselves in a formation such as a box, line, ‘I’ formation, etc.

Think of how some RTS games utilize formations if that helps understanding…

Thanks in advance!