我创建了一个扩展 Container 的自定义类。但是,当我尝试向其添加侦听器时,出现以下错误:
“TypeError:this.addEventListener 不是函数
这是我的代码的最小示例:
(function() {
var ExtendedContainerObject = function() {
this.initialize();
}
// inherit from Container
var p = ExtendedContainerObject.prototype = new createjs.Container();
p.Container_initialize = p.initialize;
p.initialize = function() {
this.Container_initialize();
console.log("this: " + this);
this.addEventListener("custom_event", function(evt){console.log("this: " + evt.target);});
this.button.onPress = function(evt) {
evt.onMouseMove = function(ev) {
dispatchEvent(new Event("custom_event", this));
}
}
}
window.ExtendedContainerObject = ExtendedContainerObject;
}());