Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 as3函数指针_Actionscript 3_Function_Pointers - Fatal编程技术网

Actionscript 3 as3函数指针

Actionscript 3 as3函数指针,actionscript-3,function,pointers,Actionscript 3,Function,Pointers,这行不通,但你能看到我在做什么吗?这有点像函数指针,或者当您将函数名传递给事件侦听器时。谢谢 您需要的是: private function myFunction(numIn:Number){ trace ("numIn " + numIn); } var plan:Object = { "theFunctionName": "myFunction" } // now use the function plan.theFunctionName(5); // should tra

这行不通,但你能看到我在做什么吗?这有点像函数指针,或者当您将函数名传递给事件侦听器时。谢谢

您需要的是:

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"

要么照雅各布的建议去做,要么你就这么做:

var plan:Object = { theFunctionName: myFunction }
// 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