You need to dynamically swap the depths of two MovieClip instances.
Use the swapChildren API.
var clip_1:MovieClip = attachMovie("blue_square", "clip_1", 1);
clip_1._x = 100;
clip_1._y = 100;
var clip_2:MovieClip = attachMovie("green_square", "clip_2", 2);
clip_2._x = 115;
clip_2._y = 115;
function onStageClick():Void
{
clip_1.swapDepths(clip_2);
}
onMouseUp = onStageClick;
var clip_1:MovieClip = new green_square();
clip_1.x = 100;
clip_1.y = 100;
var clip_2:MovieClip = new blue_square();
clip_2.x = 115;
clip_2.y = 115;
addChild(clip_1);
addChild(clip_2);
function onStageClick(event):void
{
swapChildren(clip_1, clip_2);
}
stage.addEventListener(MouseEvent.CLICK, onStageClick);