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'
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);