Best way to animate things in front and behind


I have come up with a little project where I want to have 4 balls spinning around. They’re different colours and they animate around sort of like planets orbiting the sun. Anyway, if you did this really quick in flash and animated it on a motion guide it doesn’t look like it should.

For example red is in front to begin with, green left, blue right, yellow behind. with red as top layer, blue 2nd, green 3rd and yellow bottom layer so the red is above the yellow so you can see the red over the yellow.

[COLOR=Lime]green[/COLOR] [COLOR=Blue]blue[/COLOR]

[COLOR=Black]What would be the best way to animate this so when at the next stage (going clockwise). Because when it gets to half way orbiting it looks likes this:
[COLOR=Blue]blue [/COLOR][COLOR=Lime]green[/COLOR]

[COLOR=Black]Now yellow is meant to be visible on top however because red is on the top layer, you don’t even see the yellow, you see red instead.

Is there a better way than having to change the layer position when they start to overlap?

I’m looking for a way so I can animate this and be able to change the speed of the animation if I need to.

Thanks in advance! Would really appreciate any information/help you can give me. Cheers.