private function myFunction(numIn:Number){
trace ("numIn " + numIn);
}
var plan:Object = { "theFunctionName": "myFunction" }
// now use the function
plan.theFunctionName(5);
// should trace out: "numIn 5"
This won't work, but can you see what I'm trying to do? It's kind of like a function pointer, or when you pass a function name into an event listener. Thanks.
Either do what Jacob suggested, or you can even just do:
// Your function.
function myFunction(numIn:Number):void
{
trace("numIn " + numIn);
}
// Assign "myFunction" to the property "callback" of type "Function".
var callback:Function = myFunction;
// Call "myFunction" via "callback".
callback(5); // numIn 5
What you need is:
var plan:Object = { theFunctionName: myFunction }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With