Adding Sprite to an instance of a window

Hi,
I´m trying to insert a sprite to to an instance of a window.
In insertPic() I get an error 'addChildToBack' is not a function.
The aim is to have an universal window where I can place different content. Actually the positioning doesn´t make sense. So please ignore.
Could anybody tell me how to do it?

PHP:
function Memory() {
this.initialize.apply(this, arguments);
}
var _memoryCardsFront;
var _memoryCardsBack;
var _hackingWindow;

Memory.prototype.initialize = function (hackingWindow, numOfCards){
    this._memoryCardsFront = Array(numOfCards);
    this._memoryCardsBack = Array(numOfCards);
    this._hackingWindow = hackingWindow; //the passed window where to place pictures
    this.fillArray(numOfCards);
};

Memory.prototype.fillArray = function(numOfCards){
    for(var i = 1; i<=numOfCards; i++){
        this._memoryCardsFront[i] = this.insertPic(i);
        this._memoryCardsBack[i] = this.insertPic(0);
        document.addEventListener('mousedown',    this.onMouseClick(this._memoryCardsFront));
       this._memoryCardsFront[i].visible = false;

    }
};

Memory.prototype.insertPic = function(number){

    var bitmap = new Sprite(ImageManager.loadPicture("0"+number)); //load the sprite
    this._hackingWindow.addChildToBack(bitmap); //set sprite in passed window as a child
    bitmap.setFrame(0,0,this.width,this.height); //place sprite
  
    return bitmap;
};

Memory.prototype.onMouseClick = function(object){
object.visible = true;
};

And the call from the 'mainwindow'
PHP:
this._memory = new Memory(this, 3);
Hi,
I´m trying to insert a sprite to to an instance of a window.
In insertPic() I get an error 'addChildToBack' is not a function.
The aim is to have an universal window where I can place different content. Actually the positioning doesn´t make sense. So please ignore.
Could anybody tell me how to do it?



And the call from the 'mainwindow'
if you want help.
Better structure your code.
Comment on the customize functions.
And use php balise forum for easy read.
Unfortunately I do not understand your code.
Hi Jonforum,
thanks for your time!
I haven´t found the PHP code function so I used quotes, sorry that.
The thread is now changed and the relevant parts for my question are commented. The other stuff is not important for my question.
OK, I forgot some "this."
Comming from Java and C# I really have trouble to get into JS.
Thread can be deleted.... Thanks for your time again!
you also can make construction like this in js.

PHP:
function _pixiSLL(arg) {
 this.loaded = false;
 this.libraryPath = '/SSA';
 this.JsonLibs = {};
 this.resource = {};
};
var pixiSLL = pixiSLL || new _pixiSLL(arg);


_pixiSLL.prototype.something = function(numOfCards){
 //stuf
};
OK, I forgot some "this."
Comming from Java and C# I really have trouble to get into JS.
Thread can be deleted.... Thanks for your time again!
Ok, but it's actually useful to have questions like this. Newbies learn from logic exercises.

Original thread: https://forums.rpgmakerweb.com/threads/adding-sprite-to-an-instance-of-a-window.91944/