我試圖創建一個具有createjs此事件功能的基類,然後從這個基類創建子類,但如果我再嘗試使用的addEventListener的子類的實例,我得到的錯誤:CreateJS此事件和繼承
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);
如果您正在使用EaselJS 0.7.0或以上,你可以繼承此事件相反,這是什麼EaselJS類現在要做的。 – Lanny
你的意思是我應該使用BaseClass.prototype = new createjs.EventDispatcher();在我的基類?但即使這樣也解決不了我的問題。 – BadmintonCat