Friday, January 25, 2008

Cute EcmaScript

The following is a nifty trick that works in JavaScript, but you should be able to tweak it slightly to work in ActionScript as it leverages EcmaScript features.

function Train(){ = "Choo Choo"; = function(){
var engine = new Train; = "Orient Express";
function go(){

What is cool is that you can access a function just like any other property of the object. So the go function could take a parameter that would be the name of the function to call on the engine object. It's like reflection, only better.

No comments: