You can do it with one line of code:
as2:
//container is the parent of the movieclip
movieclip.swapDepths(container.getNextHighestDepth());
as3:
//container is the parent of the movieclip
container.setChildIndex(movieclip, (container.numChildren - 1));