From badfd4b612b40076284a2bccc73cf497029bfc16 Mon Sep 17 00:00:00 2001 From: Tom Conkling Date: Tue, 27 Jan 2009 23:14:12 +0000 Subject: [PATCH] Convenience functions git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@765 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/DisplayUtil.as | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/as/com/threerings/flash/DisplayUtil.as b/src/as/com/threerings/flash/DisplayUtil.as index d426dd03..6609ec73 100644 --- a/src/as/com/threerings/flash/DisplayUtil.as +++ b/src/as/com/threerings/flash/DisplayUtil.as @@ -31,6 +31,28 @@ import flash.geom.Rectangle; public class DisplayUtil { + /** + * Adds newChild to container, directly below another child of the container. + */ + public static function addChildBelow (container :DisplayObjectContainer, + newChild :DisplayObject, + below :DisplayObject) :void + { + var ii :int = (below.parent == container ? container.getChildIndex(below) : 0); + container.addChildAt(newChild, ii); + } + + /** + * Adds newChild to container, directly above another child of the container. + */ + public static function addChildAbove (container :DisplayObjectContainer, + newChild :DisplayObject, + above :DisplayObject) :void + { + var ii :int = (above.parent == container ? container.getChildIndex(above) + 1 : 0); + container.addChildAt(newChild, ii); + } + /** * Sets the top-left pixel of a DisplayObject to the given location, relative to another * DisplayObject's coordinate space.