I am using easeljs for a HTML5 game.
I am calling onClick from within a method in a class, but the event object is overwriting my 'this' object so I can no longer access the other class methods or vars. For example I have something like (obviously this is not the actual code, just a quick illustration):
function Book(){
this.text = "this is the text";
this.makeText = function(){
//Define some shapes
var character = new Container();
character.addChild(some shapes);
character.onClick = this.detectClick;
}
this.detectClick = function(){
alert(this.text);
}
}
So, if I run this, I would get an undefined alert because in my detectClick method, this is now my event object.
So how do I call the original text from within this method?
Many Thanks