MZ Problem while making a new window.

Im pretty new at script making, I started today helping myself of some MV tutorial (even though I use MZ).
After making a scene and using addWindow on the custom window I made, because I read it wouldn't show up otherwise.
In-game loading the scene gives me the error : "Cannot read propriety 'addChild' of undefined". I can't seem to understand this error, I defined the window before and gave it in the parameters of addWindow. I'm not sure with its undefinied...
Moved to: Learning Javascript

Please show a screenshot of the console when you get the error. Your post does not include all the relevant information. Please also show another shot of your code, but let us see the line numbers.
Hi there!

First some code for reference:

JavaScript:
Scene_Base.prototype.create = function() {
    //
};

Scene_Base.prototype.createWindowLayer = function() {
    this._windowLayer = new WindowLayer();
    this._windowLayer.x = (Graphics.width - Graphics.boxWidth) / 2;
    this._windowLayer.y = (Graphics.height - Graphics.boxHeight) / 2;
    this.addChild(this._windowLayer);
};

Scene_Base.prototype.addWindow = function(window) {
    this._windowLayer.addChild(window);
};

The problem is, the .addWindow method is trying to add a child into the ._windowLayer.
But, on your scene, you don't have the ._windowLayer, since the Scene_Base.create does nothing by default.
What you need to do, is to create the window layer before you try to add a window.

But, if you replace this.addWindow with this.addChild, it will also work.
Hi there!

First some code for reference:

JavaScript:
Scene_Base.prototype.create = function() {
    //
};

Scene_Base.prototype.createWindowLayer = function() {
    this._windowLayer = new WindowLayer();
    this._windowLayer.x = (Graphics.width - Graphics.boxWidth) / 2;
    this._windowLayer.y = (Graphics.height - Graphics.boxHeight) / 2;
    this.addChild(this._windowLayer);
};

Scene_Base.prototype.addWindow = function(window) {
    this._windowLayer.addChild(window);
};

The problem is, the .addWindow method is trying to add a child into the ._windowLayer.
But, on your scene, you don't have the ._windowLayer, since the Scene_Base.create does nothing by default.
What you need to do, is to create the window layer before you try to add a window.

But, if you replace this.addWindow with this.addChild, it will also work.
I see! I will try this immediately! Thank you for the help!

Original thread: https://forums.rpgmakerweb.com/threads/problem-while-making-a-new-window.154924/