I'm currently writing a Scene structure for a game I'm making in javascript with the createjs framework. The problem I'm running into is properly referencing the original class in the prototypal functions. I'm relatively new to javascript and this is the first time I've had to use prototype. My current code is as follows:
function Intro(p, c){
this.parent = p;
var s = new createjs.Stage(c);
this.stage = s;
this.queue = new createjs.LoadQueue(false);
this.queue.installPlugin(createjs.Sound);
this.queue.addEventListener("complete", this.handleComplete);
this.queue.loadManifest([{id:"bg", src:"images/Intro/intro_background.png"}]);
}
Intro.prototype.handleComplete = function(event){
console.log("queue completed - handling...");
var q = event.target;
var bg = new createjs.Bitmap(q.getResult("bg"));
this.stage.addChild(bg);
this.stage.update();
}
When I get to
this.stage.addChild(bg);
it appears to lose scope and I get "cannot call method 'addChild' of undefined.
Any help would be greatly appreciated! -xv