forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathalignToRectangleBottom.as
More file actions
19 lines (17 loc) · 850 Bytes
/
alignToRectangleBottom.as
File metadata and controls
19 lines (17 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package utils.align
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
Aligns a DisplayObject to the bottom of the bounding Rectangle.
@param displayObject The DisplayObject to align.
@param bounds The area in which to align the DisplayObject.
@param snapToPixel Force the position to whole pixels <code>true</code>, or to let the DisplayObject be positioned on sub-pixels <code>false</code>.
@param outside Align the DisplayObject to the outside of the bounds <code>true</code>, or the inside <code>false</code>.
*/
public function alignToRectangleBottom(displayObject:DisplayObject, bounds:Rectangle, snapToPixel:Boolean = true, outside:Boolean = false):void
{
var y:Number = outside ? bounds.bottom : bounds.bottom - displayObject.height;
displayObject.y = snapToPixel ? Math.round(y) : y;
}
}