0
我创建了一个扩展容器的自定义类。然而,当我尝试将监听器添加到它,我得到以下错误:类扩展容器但不能添加事件监听器?
“类型错误: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;
}());
是的,EventDispatcher只在0.6.0添加如果你有一个旧版本,你将不得不使用回调。 – Lanny 2013-02-28 22:41:35
谢谢!这是我第一个“真正的”easelJS项目和忘记了多久以前我开始使用这些文件了!哈哈 – Ricebandit 2013-03-06 15:41:29