Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //courtesy of Colin Moock: http://www.moock.org/blog/archives/000292.html
- /**
- * Returns the distance from the registration point of the specified
- * object to the bottom-most visible pixel, ignoring any region
- * that is not visible due to masking. For example, if a display
- * object contains a 100-pixel-high shape and a 50-pixel-high mask,
- * getVisibleHeight() will return 50, whereas DisplayObject's
- * "height" variable would yield 100.
- *
- * The maximum measureable dimensions of the supplied object is
- * 2000x2000.
- */
- function getVisibleHeight (o:DisplayObject):Number {
- var bitmapDataSize:int = 2000;
- var bounds:Rectangle;
- var bitmapData:BitmapData = new BitmapData(bitmapDataSize, bitmapDataSize, true, 0);
- bitmapData.draw(o);
- bounds = bitmapData.getColorBoundsRect( 0xFF000000, 0x00000000, false );
- bitmapData.dispose();
- return bounds.y + bounds.height;
- }
- /**
- * Returns the distance from the registration point of the specified
- * object to the right-most visible pixel, ignoring any region
- * that is not visible due to masking. For example, if a display
- * object contains a 100-pixel-wide shape and a 50-pixel-wide mask,
- * getVisibleWidth() will return 50, whereas DisplayObject's
- * "width" variable would yield 100.
- *
- * The maximum measureable dimensions of the supplied object is
- * 2000x2000.
- */
- function getVisibleWidth (o:DisplayObject):Number {
- var bitmapDataSize:int = 2000;
- var bounds:Rectangle;
- var bitmapData:BitmapData = new BitmapData(bitmapDataSize, bitmapDataSize, true, 0);
- bitmapData.draw(o);
- bounds = bitmapData.getColorBoundsRect( 0xFF000000, 0x00000000, false );
- bitmapData.dispose();
- return bounds.x + bounds.width;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement