2013-10-07 1 views
0

이상한 문제가 있습니다.createjs 객체의 새 인스턴스를 만들 때마다 동일한 인스턴스가 반환됩니다.

(function() { 
    var Door = function(label, color) { 
    this.initialize(label, color); 
    } 
    var M = Door.prototype = new createjs.Container(); // inherit from Container 
    M.Container_initialize = M.initialize; 
    M.initialize = function() { 
    console.log(this); 
    } 
    window.Door = Door; 
}(window)); 

나는 시도하고 어느 곳이 개체의 새 버전을 만들 때마다 CONSOLE.LOG 출력이 나에게 같은 개체마다 제공 : 그래서 같은 createjs.Container을 확장하는 개체가 있습니다.

var door1 = new Door(); 
var door2 = new Door(); 

내가의 콘솔 출력을 얻을 : :이 할 경우 그래서

Door {id: 10, _matrix: c, children: Array[0], Container_initialize: function, initialize: function…} 
Door {id: 10, _matrix: c, children: Array[0], Container_initialize: function, initialize: function…} 

을 ... 모두 동일한 ID가 있습니다.

나는 그것이 일어날 수 있도록 내가 잘못 생각한 것인지 잘 모르겠다.

답변

0
나는 M.initialize 방법에서 하나 개의 간단한 라인을 실종됐다

:

this.Container_initialize(); 

문제를 해결!