[haXe] Dynamically called methods in haXe

Aaron Fay aaron at earthman.ca
Tue Apr 10 07:31:19 CEST 2007


Hi list,

Probably a simple answer to this one, I did some searching but sometimes 
I'm not sure what the proper 'term' is for whatever I'm searching for.

Anyhow, I need to replicate this scenario in haXe, here is an example of 
a dynamic method call that would work in flash or javascript:

//in flash
var myMethod = "foo";
_root[myMethod]();

function foo(){
    trace("bar");
}

//same kinda thing in js
var myMethod = "foo";
window[myMethod]();

function foo(){
    alert("bar");
}

Any idea how to accomplish this kind of thing in haXe? When I try a 
similar syntax, the compiler tells me 'myMethod' should be an Int...and 
I can't think of another way that might work.  Also, is there a proper 
'name' or 'term' for this type of operation?

Thanks,
Aaron





More information about the Haxe mailing list