swapDepths problem... help!

Hi,
I’m building an application with a dynamic number of boats
that move randomly around the stage. The boats are viewed
from the side. The depth of the boats is determined by the
y position; so the one with the highest y position is
‘in front’ of the others.

I loop through all the boats with a ‘for in’ loop and use
the swapDepths function to set the y value of the boat as
the depth.

When I play the movie some boats are flickering… Could this
be because the boats have the same y position and the script
gets ‘confused’? Or is it something else?

Does anyone has a solution?