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:
@@ -31,15 +31,25 @@ import flash.geom.Rectangle;
|
|||||||
|
|
||||||
public class DisplayUtil
|
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
|
* Sets the top-left pixel of a DisplayObject to the given location, taking the
|
||||||
* object's bounds into account.
|
* object's bounds into account.
|
||||||
*/
|
*/
|
||||||
public static function positionBounds (disp :DisplayObject, x :Number, y :Number) :void
|
public static function positionBounds (disp :DisplayObject, x :Number, y :Number) :void
|
||||||
{
|
{
|
||||||
var bounds :Rectangle = disp.getBounds(disp);
|
positionBoundsRelative(disp, disp, x, y);
|
||||||
disp.x = x - bounds.left;
|
|
||||||
disp.y = y - bounds.top;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user