CreateJS error: Cannot assign to read only property 'tweenjs_count' of qContainer

CreateJS error: Cannot assign to read only property 'tweenjs_count' of qContainer

我试图在函数中使用元素数组,但出现此错误

Uncaught TypeError: Cannot assign to read only property 'tweenjs_count' of qContainer.

function handleKeyDown(e)
{   
if (!e) {
  var e = window.event;
 }
     if (e.keyCode=='1'.charCodeAt(0)) {

        var imagearray = ["qContainer", "milkContainer"];
        imagearray.forEach(function(element) {
        jumpElemets(element );
     });
     jumpElemets(imagearray );
     }

     }
     function jumpElemets(element) {
     createjs.Tween.get(element, {loop: false})
        .to({alpha: 0 ,y: element.y +10}, 200, createjs.Ease.getPowInOut(2))
        .to({alpha: 1, y: element.y -10}, 200, createjs.Ease.getPowInOut(2))
        .to({alpha: 0,y: element.y }, 100, createjs.Ease.getPowInOut(2))
        .to({alpha: 1}, 100, createjs.Ease.getPowInOut(2));

}

您不能拨打jumpElemets(imagearray );。这是因为 createJS Tween 接收一个元素,而您要向它发送一个元素数组。

另外,这条线好像没什么用。我会把线完全去掉

function handleKeyDown(e)
{   
   if (!e) {
     var e = window.event;
   }
   if (e.keyCode=='1'.charCodeAt(0)) {
        var imagearray = [qContainer, milkContainer];
        imagearray.forEach(function(element) {
           jumpElemets(element );
        });
   }
}

 function jumpElemets(element) {
 createjs.Tween.get(element, {loop: false})
    .to({alpha: 0 ,y: element.y +10}, 200, createjs.Ease.getPowInOut(2))
    .to({alpha: 1, y: element.y -10}, 200, createjs.Ease.getPowInOut(2))
    .to({alpha: 0,y: element.y }, 100, createjs.Ease.getPowInOut(2))
    .to({alpha: 1}, 100, createjs.Ease.getPowInOut(2));

 }

来自 CreateJS 文档

target Object The target object that will have its properties tweened.

不是数组

http://www.createjs.com/docs/tweenjs/classes/Tween.html