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;
}());