我可以修改和编译 SDK 的 stringecho.c 示例供 AS3 使用没有问题。
对于我自己的应用程序,我使用 g++ 成功编译了几十个文件并链接:
g++ -swc -o myApp.swc glue.o demo.o obj1.o obj2.o obj3.o
我确实得到了一个 myApp.swc,但它错误地只有 80k(与简单的 stringecho 示例大小相同)。
在任何 Flash IDE 中检查时,与 stringecho.swc 不同,它具有
cmodule.stringecho.AlchemyBlock
cmodule.stringecho.AlchemyBreakPoint
...
这个 myApp.swc 有
cmodule.AlchemyBlock
cmodule.AlchemyBreakPoint
...
并且没有我定义的胶水功能。本质上,我不能在 AS3 项目中使用它。
我的glue.c 代码如下。基本上,我创建了一个演示对象并调用它的函数。演示类封装了所有其他目标文件。
#include "demo.h"
#include "AS3.h"
AS3_Val InitSystem(void* self, AS3_Val args)
{
demo = new demo9();
return 0;
}
AS3_Val LoadSceneFile( void* self, AS3_Val args )
{
demo->loadScene("scene.txt");
return 0;
}
...
int main()
{
AS3_Val InitSystemMethod = AS3_Function( NULL, InitSystem );
AS3_Val LoadSceneFileMethod = AS3_Function( NULL, LoadSceneFile );
AS3_Val getAlchemyScreenMethod = AS3_Function( NULL, getAlchemyScreen );
AS3_Val setMouseStateMethod = AS3_Function( NULL, setMouseState );
AS3_Val rasterizeMethod = AS3_Function( NULL, rasterize );
AS3_Val result = AS3_Object("InitSystem: AS3ValType,LoadSceneFile: AS3ValType,getAlchemyScreen:AS3ValType,setMouseState:AS3ValType,rasterize:AS3ValType"
,InitSystemMethod,
LoadSceneFileMethod,
getAlchemyScreenMethod,
setMouseStateMethod,
rasterizeMethod);
AS3_Release( InitSystemMethod );
AS3_Release( LoadSceneFileMethod );
AS3_Release( getAlchemyScreenMethod );
AS3_Release( setMouseStateMethod );
AS3_Release( rasterizeMethod );
AS3_LibInit( result );
return 0;
}