From d2c253af72f0819bfe2da8bb47d591931b5a5f62 Mon Sep 17 00:00:00 2001 From: Tom Conkling Date: Fri, 11 Jul 2008 22:00:19 +0000 Subject: [PATCH] DisplayUtil.positionBounds() git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@570 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/DisplayUtil.as | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/as/com/threerings/flash/DisplayUtil.as b/src/as/com/threerings/flash/DisplayUtil.as index 24f3137b..bc82de00 100644 --- a/src/as/com/threerings/flash/DisplayUtil.as +++ b/src/as/com/threerings/flash/DisplayUtil.as @@ -31,6 +31,17 @@ import flash.geom.Rectangle; public class DisplayUtil { + /** + * Sets the top-left pixel of a DisplayObject to the given location, taking the + * object's bounds into account. + */ + public static function positionBounds (disp :DisplayObject, x :Number, y :Number) :void + { + var bounds :Rectangle = disp.getBounds(disp); + disp.x = x - bounds.left; + disp.y = y - bounds.top; + } + /** * Sorts a container's children, using ArrayUtil.stableSort. *