             animTask._firstFrame = false
             animTask._waitTime = command[1]
 
-          if animTask._waitTime > animTask._elapsedTime
-            animTask._waitTime -= animTask._elapsedTime
-            animTask._elapsedTime = 0
+          if animTask._waitTime > elapsedTime
+            animTask._waitTime -= elapsedTime
+            elapsedTime = 0
           else
-            animTask._elapsedTime -= animTask._waitTime
+            elapsedTime -= animTask._waitTime
             animTask._waitTime = 0
             animTask._cmdIndex++
             animTask._firstFrame = true


          @_transform.set animTask._fromTransform if animTask._fromImageClip?

          if animTask._totalTime > animTask._elapsedTime
            animTask._currentTime += animTask._elapsedTime
            animTask._elapsedTime = 0
          else
            animTask._currentTime = animTask._totalTime
            animTask._elapsedTime -= animTask._totalTime
            animTask._cmdIndex++
            animTask._firstFrame = true


  playAnimation: (animation) ->
    animTask = new DivSugar.Task()
    animTask.animation = animation
    animTask._cmdIndex = 0
    animTask._firstFrame = true
    animTask.onUpdate = (elapsedTime) => @_updateAnimation animTask, elapsedTime
