我正在尝试创建一个具有createjs enceDispatcher功能的基类,然后从此基类创建子类,但如果我尝试在子类实例上使用addeventlistener我收到错误:

TypeError: _subClass.addEventListener is not a function
.

我的类的构造函数如下所示:

var BaseClass = function(id)
{
    _instance = this;
    _id = id;
    createjs.EventDispatcher.initialize(BaseClass.prototype);
};

var SubClass = function(id)
{
    BaseClass.call(this, id);
    SubClass.prototype = Object.create(BaseClass.prototype);
    _instance = this;
};
.

如何使其工作,以便子类继承来自BaseClass的应用程序的CreateJS事件调度程序功能?到目前为止,它只有在子类构造函数中应用事件调度程序,但不知何故忽视了继承的整体目的:

createjs.EventDispatcher.initialize(SubClass.prototype);
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top