From d22fcc041ba32cb612b91f560eebbf6eb4f240a9 Mon Sep 17 00:00:00 2001 From: Tom Conkling Date: Fri, 16 Jan 2009 23:25:16 +0000 Subject: [PATCH] DisplayUtil.positionBoundsRelative, the general version of DisplayUtil.positionBounds git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@755 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/DisplayUtil.as | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/as/com/threerings/flash/DisplayUtil.as b/src/as/com/threerings/flash/DisplayUtil.as index bc82de00..d426dd03 100644 --- a/src/as/com/threerings/flash/DisplayUtil.as +++ b/src/as/com/threerings/flash/DisplayUtil.as @@ -31,15 +31,25 @@ import flash.geom.Rectangle; public class DisplayUtil { + /** + * Sets the top-left pixel of a DisplayObject to the given location, relative to another + * DisplayObject's coordinate space. + */ + public static function positionBoundsRelative (disp :DisplayObject, relativeTo :DisplayObject, + x :Number, y :Number) :void + { + var bounds :Rectangle = disp.getBounds(relativeTo); + disp.x = x - bounds.left; + disp.y = y - bounds.top; + } + /** * 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; + positionBoundsRelative(disp, disp, x, y); } /**