package game.utils{
import flash.display.DisplayObject;
/*
burnandbass[at]gmail
util for easy managing depths / z-index in stack of a displayObject
Only works within display object's parent list
*/
public class DisplayUtil {
public function DisplayUtil() {
trace("use with static methods only!");
}
//sets the Display Object of the top of the stack
public static function sendFront(_do:DisplayObject):void {
_do.parent.setChildIndex(_do,_do.parent.numChildren - 1);
}
//sends @_do below @child
public static function sendBelow(_do:DisplayObject, child:DisplayObject):void {
_do.parent.setChildIndex(_do, _do.parent.getChildIndex(child))
}
//sets @_do above @child
public static function sendAbove(_do:DisplayObject, child:DisplayObject):void {
_do.parent.setChildIndex(_do, _do.parent.getChildIndex(child));
_do.parent.swapChildren(_do, child);
}
//sets @_do at the back of the display list stack
public static function sendBack(_do:DisplayObject):void {
_do.parent.setChildIndex(_do,0);
}
}//end
}