【问题标题】:EaselJS : .addEventListener is not a functionEaselJS:.addEventListener 不是函数
【发布时间】:2015-04-20 18:00:25
【问题描述】:

我正在尝试使用画架JS,但有些东西我无法理解。 这里是 : 我有一个包含我所有按钮的 MC。像这样(PE 和 CO 是我的按钮。它们之前在我的代码中已经初始化):

(lib.buttonsContainer = function() {
this.initialize();

// Layer 1
this.PE = new lib.PE();
this.PE.setTransform(121,163.3,2.382,2.382);

this.CO = new lib.CO();
this.CO.setTransform(135.2,59.9,2.382,2.382);

this.addChild(this.PE, this.CO);

//I give a name and an action
for(var childName in this){      
    if(this[childName] instanceof createjs.DisplayObject) {
        this[childName].name=childName;
        console.log(childName+" now has a name!!"); // it works.
        this[childName].addEventListener("click", function(evt) { alert(evt.target.parent.name); });
    }
}
}

名字如我所料,但萤火虫警告我:

this[childName].addEventListener is not a function

什么都没有显示。

由于给出了名称,我确定 this[childName] 是一个 displayObject,所以我无法弄清楚为什么 addEventListener 不被视为一个函数。

有人吗?

谢谢。

【问题讨论】:

    标签: javascript html5-canvas addeventlistener easeljs


    【解决方案1】:

    好吧,没关系。使用旧版本的easelJS (easeljs-0.5.0.min.js) Flash 导出html 文件。当我加载最后一个版本easeljs-0.8.0.min.js 时,我的代码开始工作。

    对不起。 谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-18
      • 1970-01-01
      • 2015-11-16
      • 1970-01-01
      • 2020-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多