Source: add-hit-area.js

/**
 * @function addHitArea
 * @summary
 * Use this function to set the hitArea of a movie clip.
 * @description
 * If you add a mouse/touch event to a movie clip, it requires that the hitArea be set for it to fire.
 *
 * Note: the nominal bounds of a movie clip is the area encompassing all the displayObjects (shapes, bitmaps, etc)
 * added to the movie clip using the GUI (i.e. does not include programmatically added displayObjects).
 * Animate CC automatically calculates the encompassing area and adds it to the movie clip object when the project
 * is published.
 *
 * @param {Object} options
 * @param {createjs.MovieClip} options.movieClip
 */
function addHitArea (options) {
  var MC = options.movieClip
  if (!(MC instanceof window.createjs.MovieClip)) {
    console.error('addHitArea must be called with options.movieClip')
    return
  }
  /*
   * Only movie clips created with the Animate CC App have a nominalBounds object
   */
  if (!MC.nominalBounds) {
    MC.nominalBounds = MC.getBounds()
  }
  /*
   * The hit area scales with the movie clip automatically
   */
  var width = MC.nominalBounds.width
  var height = MC.nominalBounds.height
  var x = MC.nominalBounds.x
  var y = MC.nominalBounds.y
  MC.hitArea = new window.createjs.Shape()
  MC.hitArea
    .graphics
    .beginFill('#000')
    .drawRect(x, y, width, height)
}

window.$b = window.$b || {}
window.$b.snippets = window.$b.snippets || {}
var snippets = window.$b.snippets
snippets.addHitArea = addHitArea

if (window.module) {
  window.module.exports = addHitArea
}