Actionscript 2 call function from variable
- by NebNeb
How can i call a function form a variable.
var upfunction = init;
//or
var upfunction = init();
I have tried the above code and it does not work. I want to be able to call that variable from a keypress and change the variables function. For example.
function init(){
//Do whatever
}
function init2(){
//Do another thing
}
var upfunction = init();
if (Key.getCode() == Key.UP)
{
upfunction;
}
Then later doing
upfunction = init2();
That way i could change the function without having much code. Sorry if this is a noob question but all i do is copy and paste code i have found.