适用场景:比如游戏逻辑部分用C++编写,而界面UI则采用flash,程序移植也很方便。
为什么用Adobe Alchemy,Adobe Alchemy有什么优势?
// 接口编写形式: #include "AS3.h" AS3_Val func(void* self, AS3_Val args);
// ...
即使没有返回值,不需要传入参数,接口形式也如上,否则不能成功注册。
当编译时出现如下提示,很多情况下貌似可以忽略。
For example, right before you called AS3_Function, you could have set up some struct or whatever in C, passed that as the data argument, and then you can use that inside of the function that you pass as well.
When you call AS3_Function, you're just setting up a function that can be called by ActionScript later. However, you might want to have some context to that call, and you're allowed to pass that context as data in the first argument.
Declaring a parameter as the void pointer type is kind of like the any type (*) in AS3, in that it signifies that the data can be of any type. In C, though, you will almost invariably cast the value to a known type so you can access fields from it, like: ((SomeType*) data)->someFunction().
From ActionScript, yes, but what happens behind the scenes is a bit different. Your C function will be called with that data pointer that you pass to AS3_Function when you created the callback.
This whole thing is just an Alchemy convention, though, it doesn't really have a lot to do with C.
详见http://www.kirupa.com/forum/showthread.php?356452-C-parameter-doubt