ulfben icon

getVisibleBounds in AS3

ulfben | PRO | 12/07/16 09:32:14 PM UTC | 0 ⭐ | 11328 👁️ | Never ⏰ | []
ActionScript 3 |

0 B

|

None

|

0 👍

/

0 👎

//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;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Rteuixl icon
    04/02/26 04:50:58 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
     Remove the @ 
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎