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
This commit is contained in:
Tom Conkling
2009-01-16 23:25:16 +00:00
parent dbc4c06d15
commit d22fcc041b
+13 -3
View File
@@ -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);
}
/**