/**
* @function getMovieClipBounds
* @summary
* Use this function to get the coordinates of the drop target's bounds in the coordinates
* of the target object.
* @description
* If target is not specified, then the MovieClip's parent is used.
*
* @param {Object} options
* @param {createjs.MovieClip} options.movieClip your Movie Clip instance
* @param {createjs.MovieClip=} options.target defaults to movieClip.parent
* @returns {Object<number, number, number, number>} bounds properties: left, right, top, bottom
*/
function getMovieClipBounds (options) {
var MC = options.movieClip
var target = options.target || MC.parent
if (!(MC instanceof window.createjs.MovieClip)) {
console.error('getMovieClipBounds must be called with options.movieClip')
return
}
/*
* localToLocal will handle scaling
* using nominalBounds.x & y as the corner will allow an arbitrary registration point
*/
var upperLeft = MC.localToLocal(
MC.nominalBounds.x,
MC.nominalBounds.y,
target)
var lowerRight = MC.localToLocal(
MC.nominalBounds.x + MC.nominalBounds.width,
MC.nominalBounds.y + MC.nominalBounds.height,
target)
return {
left: upperLeft.x,
right: lowerRight.x,
top: upperLeft.y,
bottom: lowerRight.y
}
}
window.$b = window.$b || {}
window.$b.snippets = window.$b.snippets || {}
var snippets = window.$b.snippets
snippets.getMovieClipBounds = getMovieClipBounds
if (window.module) {
window.module.exports = getMovieClipBounds
}