Although FABridge is a nice tool, it's got its shortcomings. I am going to fix one of them now, namely that it doesn't give you real properties, but uses Java's getter setter convention instead. In 3 out 4 browsers, the __defineSetter__ and __defineGetter__ methods are already usable, so why not take advantage? It's really easy as it turned out. Change the addPropertyToType method to:
addPropertyToType: function(ty, propName)
{
var c = propName.charAt(0);
var setterName;
var getterName;
if(c >= "a" && c <= "z")
{
getterName = "get" + c.toUpperCase() + propName.substr(1);
setterName = "set" + c.toUpperCase() + propName.substr(1);
}
else
{
getterName = "get" + propName;
setterName = "set" + propName;
}
function setter(val)
{
this.bridge.setPropertyInAS(this.fb_instance_id, propName, val);
}
ty[setterName] = setter;
function getter()
{
return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, propName));
}
ty[getterName] = getter;
if (ty.__defineGetter__)
ty.__defineGetter__(propName, getter);
if (ty.__defineSetter__)
ty.__defineSetter__(propName, setter);
},
And..., voila! You got yourself real properties. Now instead of writing:
app.getTextBox()
You will be much happier writting:
app.textBox
On non-sucky browsers that is.