 
     anim = new createjs.MovieClip()
     anim.initialize(mode ? createjs.MovieClip.INDEPENDENT, startPosition ? 0, loops ? true)
+    anim.specialGoToAndStop = specialGoToAndStop
 
     for tweenData in animData.tweens
       stopped = false

    @currentFrame = newFrame
    return if translatedFrame is @baseMovieClip.currentFrame

    @baseMovieClip.gotoAndStop(translatedFrame)
    movieClip.gotoAndStop(newFrame) for movieClip in @childMovieClips
    @children = []
    @takeChildrenFromMovieClip()
    
  takeChildrenFromMovieClip: ->
    i = 0
    while i < @baseMovieClip.children.length
      child = @baseMovieClip.children[i]
      if child instanceof createjs.MovieClip
        newChild = new createjs.SpriteContainer(@spriteSheet)
        j = 0
        while j < child.children.length
          grandChild = child.children[j]
          if grandChild instanceof createjs.MovieClip
            console.error('MovieClip Segmentedsprites not currently working at this depth!')
            continue
          newChild.addChild(grandChild)
          for prop in ['regX', 'regY', 'rotation', 'scaleX', 'scaleY', 'skewX', 'skewY', 'x', 'y']
            newChild[prop] = child[prop]
        @addChild(newChild)
        i += 1
      else
        @addChild(child)
    

#  _getBounds: createjs.SpriteContainer.prototype.getBounds

SpriteBuilder = require 'lib/sprites/SpriteBuilder'

# Put this on MovieClips
specialGoToAndStop = (frame) ->
  if frame is @currentFrame and @childrenCopy
    @addChild(@childrenCopy...)
  else
    @gotoAndStop(frame)
    @childrenCopy = @children.slice(0)

module.exports = class SegmentedSprite extends createjs.SpriteContainer
  childMovieClips: null
