EaselJS:.addEventListener不是函数

EaselJS : .addEventListener is not a function

本文关键字:函数 addEventListener EaselJS      更新时间:2024-01-29

我正在尝试使用easeJS,但有些地方我无法理解。它在这里:我有一个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); });
    }
}
}

名字如我所料,但firebug警告我:

this[childName].addEventListener is not a function

并且什么也不显示。

由于给出了名称,我确信这个[childName]是一个displayObject,所以我不明白为什么addEventListener不被视为一个函数。

有人吗?

谢谢。

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

对不起。谢谢