package com.exanimo.utils { import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; /** * * Utility functions for dealing with DisplayObjects and * DisplayObjectContainers. * * @author matthew at exanimo dot com * @author Ryan Sprake * */ public class DisplayObjectUtil { /** * @private */ public function DisplayObjectUtil() { throw new Error('DisplayObjectUtil contains static utility methods and cannot be instantialized.'); } ///////////////////////////////////////////////////////////////////////////// // // depth management functions: bringToFront, sendToBack // ///////////////////////////////////////////////////////////////////////////// /** * * Brings a DisplayObject to the front within its parent. * * @param child * the DisplayObject to reposition * */ public static function bringToFront(child:DisplayObject):void { var parent:DisplayObjectContainer; if (!(parent = child.parent)) return; parent.setChildIndex(child, parent.numChildren - 1); } /** * * Sends a DisplayObject to the back within its parent. * * @param child * the DisplayObject to reposition * */ public static function sendToBack(child:DisplayObject):void { var parent:DisplayObjectContainer; if (!(parent = child.parent)) return; parent.setChildIndex(child, 0); } } }