# swapDepths problem... help!

**URL:** <https://forum.kirupa.com/t/swapdepths-problem-help/148396>\
**Category:** Uncategorized\
**Created:** [May 19, 2005, 4:05pm UTC](https://forum.kirupa.com/t/swapdepths-problem-help/148396 "2005-05-19T16:05:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![albert105](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@albert105](https://forum.kirupa.com/u/albert105)\
**Post date:** [May 19, 2005, 4:05pm UTC](https://forum.kirupa.com/t/swapdepths-problem-help/148396/1 "2005-05-19T16:05:43Z")

</div>

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?
