I've troubleshooted my problem. It's because I used the wrong syntax to create a new KONtx.Class. Basically, I define a class like this:
CODE
var ScoreboardContent = new KONtx.Class({
ClassName: 'ScoreboardContent',
Extends: KONtx.element.Container,
config: {
}
});
I created a instance of this class like this:
CODE
var scoreboard = ScoreboardContent({
});
I changed to this:
CODE
var scoreboard = new ScoreboardContent({
});
It solved the problem! But I think the framework need to be improved here, because it gave a misleading error message which is hard to track down the real problem.
I disagree. How is a function supposed to know whether it's supposed to be used as a constructor? If you're getting a type error, clearly you're trying to treat a data type as it's not intended to be treated. That in itself is a good indication as to where to start troubleshooting.
Your implication of improving the framework would lead to a lot of hand-holding like the following code, which I think is a really bad idea.
CODE
function Person(name) {
if (!(this instanceof arguments.callee)) {
log("isn't this supposed to be a constructor?");
log("instantiating it for you...");
return new arguments.callee(name);
}
this.name = name;
}
var obj = Person("Ben");
log(obj.name); //logs "Ben"
There are many values to using a framework, but I don't believe that one of them is to anticipate all the ways a developer could misuse the language. That's simply impossible.